src/Doc/Tutorial/Documents/Documents.thy
author wenzelm
Sat, 05 Jan 2019 17:24:33 +0100
changeset 69597 ff784d5a5bfb
parent 69505 cc2d676d5395
child 76987 4c275405faae
permissions -rw-r--r--
isabelle update -u control_cartouches;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11647
0538cb0f7999 initial setup for chapter on document preparation;
wenzelm
parents:
diff changeset
     1
(*<*)
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 15141
diff changeset
     2
theory Documents imports Main begin
11647
0538cb0f7999 initial setup for chapter on document preparation;
wenzelm
parents:
diff changeset
     3
(*>*)
0538cb0f7999 initial setup for chapter on document preparation;
wenzelm
parents:
diff changeset
     4
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
     5
section \<open>Concrete Syntax \label{sec:concrete-syntax}\<close>
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
     6
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
     7
text \<open>
12766
wenzelm
parents: 12764
diff changeset
     8
  The core concept of Isabelle's framework for concrete syntax is that
wenzelm
parents: 12764
diff changeset
     9
  of \bfindex{mixfix annotations}.  Associated with any kind of
wenzelm
parents: 12764
diff changeset
    10
  constant declaration, mixfixes affect both the grammar productions
wenzelm
parents: 12764
diff changeset
    11
  for the parser and output templates for the pretty printer.
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    12
12743
wenzelm
parents: 12685
diff changeset
    13
  In full generality, parser and pretty printer configuration is a
58620
7435b6a3f72e more antiquotations;
wenzelm
parents: 54936
diff changeset
    14
  subtle affair~@{cite "isabelle-isar-ref"}.  Your syntax specifications need
12766
wenzelm
parents: 12764
diff changeset
    15
  to interact properly with the existing setup of Isabelle/Pure and
wenzelm
parents: 12764
diff changeset
    16
  Isabelle/HOL\@.  To avoid creating ambiguities with existing
wenzelm
parents: 12764
diff changeset
    17
  elements, it is particularly important to give new syntactic
12764
b43333dc6e7d stylistic changes
paulson
parents: 12750
diff changeset
    18
  constructs the right precedence.
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    19
25338
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
    20
  Below we introduce a few simple syntax declaration
12743
wenzelm
parents: 12685
diff changeset
    21
  forms that already cover many common situations fairly well.
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
    22
\<close>
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    23
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    24
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
    25
subsection \<open>Infix Annotations\<close>
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    26
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
    27
text \<open>
12764
b43333dc6e7d stylistic changes
paulson
parents: 12750
diff changeset
    28
  Syntax annotations may be included wherever constants are declared,
27015
f8537d69f514 *** empty log message ***
nipkow
parents: 26698
diff changeset
    29
  such as \isacommand{definition} and \isacommand{primrec} --- and also
12766
wenzelm
parents: 12764
diff changeset
    30
  \isacommand{datatype}, which declares constructor operations.
wenzelm
parents: 12764
diff changeset
    31
  Type-constructors may be annotated as well, although this is less
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
    32
  frequently encountered in practice (the infix type \<open>\<times>\<close> comes
12766
wenzelm
parents: 12764
diff changeset
    33
  to mind).
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    34
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
    35
  Infix declarations\index{infix annotations} provide a useful special
12766
wenzelm
parents: 12764
diff changeset
    36
  case of mixfixes.  The following example of the exclusive-or
wenzelm
parents: 12764
diff changeset
    37
  operation on boolean values illustrates typical infix declarations.
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
    38
\<close>
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    39
27015
f8537d69f514 *** empty log message ***
nipkow
parents: 26698
diff changeset
    40
definition xor :: "bool \<Rightarrow> bool \<Rightarrow> bool"    (infixl "[+]" 60)
f8537d69f514 *** empty log message ***
nipkow
parents: 26698
diff changeset
    41
where "A [+] B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)"
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    42
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
    43
text \<open>
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
    44
  \noindent Now \<open>xor A B\<close> and \<open>A [+] B\<close> refer to the
12653
wenzelm
parents: 12651
diff changeset
    45
  same expression internally.  Any curried function with at least two
12766
wenzelm
parents: 12764
diff changeset
    46
  arguments may be given infix syntax.  For partial applications with
67398
5eb932e604a2 Manual updates towards conversion of "op" syntax
nipkow
parents: 67042
diff changeset
    47
  fewer than two operands, the operator is enclosed in parentheses.
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
    48
  For instance, \<open>xor\<close> without arguments is represented as
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
    49
  \<open>([+])\<close>; together with ordinary function application, this
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
    50
  turns \<open>xor A\<close> into \<open>([+]) A\<close>.
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    51
25338
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
    52
  The keyword \isakeyword{infixl} seen above specifies an
12746
wenzelm
parents: 12744
diff changeset
    53
  infix operator that is nested to the \emph{left}: in iterated
wenzelm
parents: 12744
diff changeset
    54
  applications the more complex expression appears on the left-hand
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 69505
diff changeset
    55
  side, and \<^term>\<open>A [+] B [+] C\<close> stands for \<open>(A [+] B) [+]
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
    56
  C\<close>.  Similarly, \isakeyword{infixr} means nesting to the
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 69505
diff changeset
    57
  \emph{right}, reading \<^term>\<open>A [+] B [+] C\<close> as \<open>A [+] (B
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
    58
  [+] C)\<close>.  A \emph{non-oriented} declaration via \isakeyword{infix}
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 69505
diff changeset
    59
  would render \<^term>\<open>A [+] B [+] C\<close> illegal, but demand explicit
12766
wenzelm
parents: 12764
diff changeset
    60
  parentheses to indicate the intended grouping.
12743
wenzelm
parents: 12685
diff changeset
    61
12746
wenzelm
parents: 12744
diff changeset
    62
  The string @{text [source] "[+]"} in our annotation refers to the
wenzelm
parents: 12744
diff changeset
    63
  concrete syntax to represent the operator (a literal token), while
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
    64
  the number \<open>60\<close> determines the precedence of the construct:
12766
wenzelm
parents: 12764
diff changeset
    65
  the syntactic priorities of the arguments and result.  Isabelle/HOL
wenzelm
parents: 12764
diff changeset
    66
  already uses up many popular combinations of ASCII symbols for its
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
    67
  own use, including both \<open>+\<close> and \<open>++\<close>.  Longer
12766
wenzelm
parents: 12764
diff changeset
    68
  character combinations are more likely to be still available for
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
    69
  user extensions, such as our~\<open>[+]\<close>.
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    70
12766
wenzelm
parents: 12764
diff changeset
    71
  Operator precedences have a range of 0--1000.  Very low or high
wenzelm
parents: 12764
diff changeset
    72
  priorities are reserved for the meta-logic.  HOL syntax mainly uses
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
    73
  the range of 10--100: the equality infix \<open>=\<close> is centered at
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
    74
  50; logical connectives (like \<open>\<or>\<close> and \<open>\<and>\<close>) are
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
    75
  below 50; algebraic ones (like \<open>+\<close> and \<open>*\<close>) are
12766
wenzelm
parents: 12764
diff changeset
    76
  above 50.  User syntax should strive to coexist with common HOL
wenzelm
parents: 12764
diff changeset
    77
  forms, or use the mostly unused range 100--900.
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
    78
\<close>
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    79
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
    80
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
    81
subsection \<open>Mathematical Symbols \label{sec:syntax-symbols}\<close>
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    82
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
    83
text \<open>
12766
wenzelm
parents: 12764
diff changeset
    84
  Concrete syntax based on ASCII characters has inherent limitations.
wenzelm
parents: 12764
diff changeset
    85
  Mathematical notation demands a larger repertoire of glyphs.
wenzelm
parents: 12764
diff changeset
    86
  Several standards of extended character sets have been proposed over
wenzelm
parents: 12764
diff changeset
    87
  decades, but none has become universally available so far.  Isabelle
wenzelm
parents: 12764
diff changeset
    88
  has its own notion of \bfindex{symbols} as the smallest entities of
wenzelm
parents: 12764
diff changeset
    89
  source text, without referring to internal encodings.  There are
wenzelm
parents: 12764
diff changeset
    90
  three kinds of such ``generalized characters'':
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
    91
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
    92
  \begin{enumerate}
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
    93
12653
wenzelm
parents: 12651
diff changeset
    94
  \item 7-bit ASCII characters
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
    95
12653
wenzelm
parents: 12651
diff changeset
    96
  \item named symbols: \verb,\,\verb,<,$ident$\verb,>,
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
    97
12653
wenzelm
parents: 12651
diff changeset
    98
  \item named control symbols: \verb,\,\verb,<^,$ident$\verb,>,
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
    99
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   100
  \end{enumerate}
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   101
14486
74c053a25513 symbols in idents
kleing
parents: 14353
diff changeset
   102
  Here $ident$ is any sequence of letters. 
74c053a25513 symbols in idents
kleing
parents: 14353
diff changeset
   103
  This results in an infinite store of symbols, whose
12766
wenzelm
parents: 12764
diff changeset
   104
  interpretation is left to further front-end tools.  For example, the
58842
22b87ab47d3b discontinued Proof General;
wenzelm
parents: 58620
diff changeset
   105
  Isabelle document processor (see \S\ref{sec:document-preparation})
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   106
  display the \verb,\,\verb,<forall>, symbol as~\<open>\<forall>\<close>.
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   107
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   108
  A list of standard Isabelle symbols is given in
58620
7435b6a3f72e more antiquotations;
wenzelm
parents: 54936
diff changeset
   109
  @{cite "isabelle-isar-ref"}.  You may introduce your own
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   110
  interpretation of further symbols by configuring the appropriate
12653
wenzelm
parents: 12651
diff changeset
   111
  front-end tool accordingly, e.g.\ by defining certain {\LaTeX}
wenzelm
parents: 12651
diff changeset
   112
  macros (see also \S\ref{sec:doc-prep-symbols}).  There are also a
wenzelm
parents: 12651
diff changeset
   113
  few predefined control symbols, such as \verb,\,\verb,<^sub>, and
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   114
  \verb,\,\verb,<^sup>, for sub- and superscript of the subsequent
61593
810486f886bf more antiquotations;
wenzelm
parents: 60270
diff changeset
   115
  printable symbol, respectively.  For example, \<^verbatim>\<open>A\<^sup>\<star>\<close>, is
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   116
  output as \<open>A\<^sup>\<star>\<close>.
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   117
17183
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   118
  A number of symbols are considered letters by the Isabelle lexer and
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   119
  can be used as part of identifiers. These are the greek letters
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   120
  \<open>\<alpha>\<close> (\verb+\+\verb+<alpha>+), \<open>\<beta>\<close>
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   121
  (\verb+\+\verb+<beta>+), etc. (excluding \<open>\<lambda>\<close>),
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   122
  special letters like \<open>\<A>\<close> (\verb+\+\verb+<A>+) and \<open>\<AA>\<close> (\verb+\+\verb+<AA>+).  Moreover the control symbol
52919
a2659fbb3b13 prefer plain subscript for identifiers;
wenzelm
parents: 51057
diff changeset
   123
  \verb+\+\verb+<^sub>+ may be used to subscript a single letter or digit
a2659fbb3b13 prefer plain subscript for identifiers;
wenzelm
parents: 51057
diff changeset
   124
  in the trailing part of an identifier. This means that the input
14486
74c053a25513 symbols in idents
kleing
parents: 14353
diff changeset
   125
74c053a25513 symbols in idents
kleing
parents: 14353
diff changeset
   126
  \medskip
61593
810486f886bf more antiquotations;
wenzelm
parents: 60270
diff changeset
   127
  {\small\noindent \<^verbatim>\<open>\<forall>\<alpha>\<^sub>1. \<alpha>\<^sub>1 = \<Pi>\<^sub>\<A>\<close>}
14486
74c053a25513 symbols in idents
kleing
parents: 14353
diff changeset
   128
74c053a25513 symbols in idents
kleing
parents: 14353
diff changeset
   129
  \medskip
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 69505
diff changeset
   130
  \noindent is recognized as the term \<^term>\<open>\<forall>\<alpha>\<^sub>1. \<alpha>\<^sub>1 = \<Pi>\<^sub>\<A>\<close> 
52919
a2659fbb3b13 prefer plain subscript for identifiers;
wenzelm
parents: 51057
diff changeset
   131
  by Isabelle.
14486
74c053a25513 symbols in idents
kleing
parents: 14353
diff changeset
   132
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   133
  Replacing our previous definition of \<open>xor\<close> by the
17183
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   134
  following specifies an Isabelle symbol for the new operator:
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   135
\<close>
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   136
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   137
(*<*)
36176
3fe7e97ccca8 replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents: 30649
diff changeset
   138
hide_const xor
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   139
setup \<open>Sign.add_path "version1"\<close>
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   140
(*>*)
27015
f8537d69f514 *** empty log message ***
nipkow
parents: 26698
diff changeset
   141
definition xor :: "bool \<Rightarrow> bool \<Rightarrow> bool"    (infixl "\<oplus>" 60)
f8537d69f514 *** empty log message ***
nipkow
parents: 26698
diff changeset
   142
where "A \<oplus> B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)"
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   143
(*<*)
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   144
setup \<open>Sign.local_path\<close>
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   145
(*>*)
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   146
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   147
text \<open>
58842
22b87ab47d3b discontinued Proof General;
wenzelm
parents: 58620
diff changeset
   148
  It is possible to provide alternative syntax forms
58620
7435b6a3f72e more antiquotations;
wenzelm
parents: 54936
diff changeset
   149
  through the \bfindex{print mode} concept~@{cite "isabelle-isar-ref"}.  By
12766
wenzelm
parents: 12764
diff changeset
   150
  convention, the mode of ``$xsymbols$'' is enabled whenever
wenzelm
parents: 12764
diff changeset
   151
  Proof~General's X-Symbol mode or {\LaTeX} output is active.  Now
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   152
  consider the following hybrid declaration of \<open>xor\<close>:
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   153
\<close>
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   154
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   155
(*<*)
36176
3fe7e97ccca8 replaced generic 'hide' command by more conventional 'hide_class', 'hide_type', 'hide_const', 'hide_fact' -- frees some popular keywords;
wenzelm
parents: 30649
diff changeset
   156
hide_const xor
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   157
setup \<open>Sign.add_path "version2"\<close>
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   158
(*>*)
27015
f8537d69f514 *** empty log message ***
nipkow
parents: 26698
diff changeset
   159
definition xor :: "bool \<Rightarrow> bool \<Rightarrow> bool"    (infixl "[+]\<ignore>" 60)
f8537d69f514 *** empty log message ***
nipkow
parents: 26698
diff changeset
   160
where "A [+]\<ignore> B \<equiv> (A \<and> \<not> B) \<or> (\<not> A \<and> B)"
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   161
25338
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   162
notation (xsymbols) xor (infixl "\<oplus>\<ignore>" 60)
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   163
(*<*)
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   164
setup \<open>Sign.local_path\<close>
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   165
(*>*)
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   166
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   167
text \<open>\noindent
27015
f8537d69f514 *** empty log message ***
nipkow
parents: 26698
diff changeset
   168
The \commdx{notation} command associates a mixfix
f8537d69f514 *** empty log message ***
nipkow
parents: 26698
diff changeset
   169
annotation with a known constant.  The print mode specification,
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   170
here \<open>(xsymbols)\<close>, is optional.
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   171
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   172
We may now write \<open>A [+] B\<close> or \<open>A \<oplus> B\<close> in input, while
25338
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   173
output uses the nicer syntax of $xsymbols$ whenever that print mode is
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   174
active.  Such an arrangement is particularly useful for interactive
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   175
development, where users may type ASCII text and see mathematical
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   176
symbols displayed during proofs.\<close>
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   177
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   178
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   179
subsection \<open>Prefix Annotations\<close>
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   180
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   181
text \<open>
12766
wenzelm
parents: 12764
diff changeset
   182
  Prefix syntax annotations\index{prefix annotation} are another form
58620
7435b6a3f72e more antiquotations;
wenzelm
parents: 54936
diff changeset
   183
  of mixfixes @{cite "isabelle-isar-ref"}, without any template arguments or
12766
wenzelm
parents: 12764
diff changeset
   184
  priorities --- just some literal syntax.  The following example
wenzelm
parents: 12764
diff changeset
   185
  associates common symbols with the constructors of a datatype.
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   186
\<close>
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   187
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   188
datatype currency =
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   189
    Euro nat    ("\<euro>")
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   190
  | Pounds nat  ("\<pounds>")
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   191
  | Yen nat     ("\<yen>")
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   192
  | Dollar nat  ("$")
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   193
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   194
text \<open>
12653
wenzelm
parents: 12651
diff changeset
   195
  \noindent Here the mixfix annotations on the rightmost column happen
wenzelm
parents: 12651
diff changeset
   196
  to consist of a single Isabelle symbol each: \verb,\,\verb,<euro>,,
wenzelm
parents: 12651
diff changeset
   197
  \verb,\,\verb,<pounds>,, \verb,\,\verb,<yen>,, and \verb,$,.  Recall
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 69505
diff changeset
   198
  that a constructor like \<open>Euro\<close> actually is a function \<^typ>\<open>nat \<Rightarrow> currency\<close>.  The expression \<open>Euro 10\<close> will be
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 69505
diff changeset
   199
  printed as \<^term>\<open>\<euro> 10\<close>; only the head of the application is
12743
wenzelm
parents: 12685
diff changeset
   200
  subject to our concrete syntax.  This rather simple form already
wenzelm
parents: 12685
diff changeset
   201
  achieves conformance with notational standards of the European
wenzelm
parents: 12685
diff changeset
   202
  Commission.
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   203
27015
f8537d69f514 *** empty log message ***
nipkow
parents: 26698
diff changeset
   204
  Prefix syntax works the same way for other commands that introduce new constants, e.g. \isakeyword{primrec}.
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   205
\<close>
12651
930df4604b36 some more ...;
wenzelm
parents: 12648
diff changeset
   206
930df4604b36 some more ...;
wenzelm
parents: 12648
diff changeset
   207
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   208
subsection \<open>Abbreviations \label{sec:abbreviations}\<close>
12651
930df4604b36 some more ...;
wenzelm
parents: 12648
diff changeset
   209
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   210
text\<open>Mixfix syntax annotations merely decorate particular constant
25338
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   211
application forms with concrete syntax, for instance replacing
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   212
\<open>xor A B\<close> by \<open>A \<oplus> B\<close>.  Occasionally, the relationship
25338
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   213
between some piece of notation and its internal form is more
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   214
complicated.  Here we need \emph{abbreviations}.
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   215
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   216
Command \commdx{abbreviation} introduces an uninterpreted notational
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   217
constant as an abbreviation for a complex term. Abbreviations are
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   218
unfolded upon parsing and re-introduced upon printing. This provides a
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   219
simple mechanism for syntactic macros.
12651
930df4604b36 some more ...;
wenzelm
parents: 12648
diff changeset
   220
25338
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   221
A typical use of abbreviations is to introduce relational notation for
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   222
membership in a set of pairs, replacing \<open>(x, y) \<in> sim\<close> by
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   223
\<open>x \<approx> y\<close>. We assume that a constant \<open>sim\<close> of type
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 69505
diff changeset
   224
\<^typ>\<open>('a \<times> 'a) set\<close> has been introduced at this point.\<close>
27015
f8537d69f514 *** empty log message ***
nipkow
parents: 26698
diff changeset
   225
(*<*)consts sim :: "('a \<times> 'a) set"(*>*)
25338
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   226
abbreviation sim2 :: "'a \<Rightarrow> 'a \<Rightarrow> bool"   (infix "\<approx>" 50)
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   227
where "x \<approx> y  \<equiv>  (x, y) \<in> sim"
12651
930df4604b36 some more ...;
wenzelm
parents: 12648
diff changeset
   228
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   229
text \<open>\noindent The given meta-equality is used as a rewrite rule
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 69505
diff changeset
   230
after parsing (replacing \mbox{\<^prop>\<open>x \<approx> y\<close>} by \<open>(x,y) \<in>
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   231
sim\<close>) and before printing (turning \<open>(x,y) \<in> sim\<close> back into
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 69505
diff changeset
   232
\mbox{\<^prop>\<open>x \<approx> y\<close>}). The name of the dummy constant \<open>sim2\<close>
25338
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   233
does not matter, as long as it is unique.
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   234
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   235
Another common application of abbreviations is to
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   236
provide variant versions of fundamental relational expressions, such
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   237
as \<open>\<noteq>\<close> for negated equalities.  The following declaration
25338
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   238
stems from Isabelle/HOL itself:
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   239
\<close>
12635
e2d44df29c94 more on concrete syntax;
wenzelm
parents: 12629
diff changeset
   240
25338
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   241
abbreviation not_equal :: "'a \<Rightarrow> 'a \<Rightarrow> bool"    (infixl "~=\<ignore>" 50)
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   242
where "x ~=\<ignore> y  \<equiv>  \<not> (x = y)"
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   243
25338
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   244
notation (xsymbols) not_equal (infix "\<noteq>\<ignore>" 50)
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   245
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   246
text \<open>\noindent The notation \<open>\<noteq>\<close> is introduced separately to restrict it
25338
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   247
to the \emph{xsymbols} mode.
12651
930df4604b36 some more ...;
wenzelm
parents: 12648
diff changeset
   248
27015
f8537d69f514 *** empty log message ***
nipkow
parents: 26698
diff changeset
   249
Abbreviations are appropriate when the defined concept is a
25338
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   250
simple variation on an existing one.  But because of the automatic
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   251
folding and unfolding of abbreviations, they do not scale up well to
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   252
large hierarchies of concepts. Abbreviations do not replace
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   253
definitions.
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   254
25338
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   255
Abbreviations are a simplified form of the general concept of
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   256
\emph{syntax translations}; even heavier transformations may be
58620
7435b6a3f72e more antiquotations;
wenzelm
parents: 54936
diff changeset
   257
written in ML @{cite "isabelle-isar-ref"}.
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   258
\<close>
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   259
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   260
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   261
section \<open>Document Preparation \label{sec:document-preparation}\<close>
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   262
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   263
text \<open>
12653
wenzelm
parents: 12651
diff changeset
   264
  Isabelle/Isar is centered around the concept of \bfindex{formal
12766
wenzelm
parents: 12764
diff changeset
   265
  proof documents}\index{documents|bold}.  The outcome of a formal
wenzelm
parents: 12764
diff changeset
   266
  development effort is meant to be a human-readable record, presented
wenzelm
parents: 12764
diff changeset
   267
  as browsable PDF file or printed on paper.  The overall document
wenzelm
parents: 12764
diff changeset
   268
  structure follows traditional mathematical articles, with sections,
wenzelm
parents: 12764
diff changeset
   269
  intermediate explanations, definitions, theorems and proofs.
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   270
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   271
  \medskip The Isabelle document preparation system essentially acts
12670
wenzelm
parents: 12665
diff changeset
   272
  as a front-end to {\LaTeX}.  After checking specifications and
wenzelm
parents: 12665
diff changeset
   273
  proofs formally, the theory sources are turned into typesetting
12766
wenzelm
parents: 12764
diff changeset
   274
  instructions in a schematic manner.  This lets you write authentic
wenzelm
parents: 12764
diff changeset
   275
  reports on theory developments with little effort: many technical
wenzelm
parents: 12764
diff changeset
   276
  consistency checks are handled by the system.
12744
wenzelm
parents: 12743
diff changeset
   277
wenzelm
parents: 12743
diff changeset
   278
  Here is an example to illustrate the idea of Isabelle document
wenzelm
parents: 12743
diff changeset
   279
  preparation.
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   280
\<close>
12744
wenzelm
parents: 12743
diff changeset
   281
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   282
text_raw \<open>\begin{quotation}\<close>
12746
wenzelm
parents: 12744
diff changeset
   283
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   284
text \<open>
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   285
  The following datatype definition of \<open>'a bintree\<close> models
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 69505
diff changeset
   286
  binary trees with nodes being decorated by elements of type \<^typ>\<open>'a\<close>.
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   287
\<close>
12744
wenzelm
parents: 12743
diff changeset
   288
wenzelm
parents: 12743
diff changeset
   289
datatype 'a bintree =
12746
wenzelm
parents: 12744
diff changeset
   290
     Leaf | Branch 'a  "'a bintree"  "'a bintree"
12744
wenzelm
parents: 12743
diff changeset
   291
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   292
text \<open>
12744
wenzelm
parents: 12743
diff changeset
   293
  \noindent The datatype induction rule generated here is of the form
12746
wenzelm
parents: 12744
diff changeset
   294
  @{thm [indent = 1, display] bintree.induct [no_vars]}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   295
\<close>
12744
wenzelm
parents: 12743
diff changeset
   296
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   297
text_raw \<open>\end{quotation}\<close>
12746
wenzelm
parents: 12744
diff changeset
   298
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   299
text \<open>
12766
wenzelm
parents: 12764
diff changeset
   300
  \noindent The above document output has been produced as follows:
12744
wenzelm
parents: 12743
diff changeset
   301
wenzelm
parents: 12743
diff changeset
   302
  \begin{ttbox}
wenzelm
parents: 12743
diff changeset
   303
  text {\ttlbrace}*
wenzelm
parents: 12743
diff changeset
   304
    The following datatype definition of {\at}{\ttlbrace}text "'a bintree"{\ttrbrace}
wenzelm
parents: 12743
diff changeset
   305
    models binary trees with nodes being decorated by elements
wenzelm
parents: 12743
diff changeset
   306
    of type {\at}{\ttlbrace}typ 'a{\ttrbrace}.
wenzelm
parents: 12743
diff changeset
   307
  *{\ttrbrace}
wenzelm
parents: 12743
diff changeset
   308
wenzelm
parents: 12743
diff changeset
   309
  datatype 'a bintree =
wenzelm
parents: 12743
diff changeset
   310
    Leaf | Branch 'a  "'a bintree"  "'a bintree"
12766
wenzelm
parents: 12764
diff changeset
   311
  \end{ttbox}
wenzelm
parents: 12764
diff changeset
   312
  \begin{ttbox}
12744
wenzelm
parents: 12743
diff changeset
   313
  text {\ttlbrace}*
wenzelm
parents: 12743
diff changeset
   314
    {\ttback}noindent The datatype induction rule generated here is
wenzelm
parents: 12743
diff changeset
   315
    of the form {\at}{\ttlbrace}thm [display] bintree.induct [no_vars]{\ttrbrace}
wenzelm
parents: 12743
diff changeset
   316
  *{\ttrbrace}
12766
wenzelm
parents: 12764
diff changeset
   317
  \end{ttbox}\vspace{-\medskipamount}
12744
wenzelm
parents: 12743
diff changeset
   318
12746
wenzelm
parents: 12744
diff changeset
   319
  \noindent Here we have augmented the theory by formal comments
12766
wenzelm
parents: 12764
diff changeset
   320
  (using \isakeyword{text} blocks), the informal parts may again refer
wenzelm
parents: 12764
diff changeset
   321
  to formal entities by means of ``antiquotations'' (such as
12744
wenzelm
parents: 12743
diff changeset
   322
  \texttt{\at}\verb,{text "'a bintree"}, or
12746
wenzelm
parents: 12744
diff changeset
   323
  \texttt{\at}\verb,{typ 'a},), see also \S\ref{sec:doc-prep-text}.
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   324
\<close>
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   325
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   326
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   327
subsection \<open>Isabelle Sessions\<close>
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   328
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   329
text \<open>
12653
wenzelm
parents: 12651
diff changeset
   330
  In contrast to the highly interactive mode of Isabelle/Isar theory
wenzelm
parents: 12651
diff changeset
   331
  development, the document preparation stage essentially works in
12670
wenzelm
parents: 12665
diff changeset
   332
  batch-mode.  An Isabelle \bfindex{session} consists of a collection
12766
wenzelm
parents: 12764
diff changeset
   333
  of source files that may contribute to an output document.  Each
wenzelm
parents: 12764
diff changeset
   334
  session is derived from a single parent, usually an object-logic
wenzelm
parents: 12764
diff changeset
   335
  image like \texttt{HOL}.  This results in an overall tree structure,
wenzelm
parents: 12764
diff changeset
   336
  which is reflected by the output location in the file system
54936
30e2503f1aa2 more formal ISABELLE_BROWSER_INFO;
wenzelm
parents: 53015
diff changeset
   337
  (the root directory is determined by the Isabelle settings variable
30e2503f1aa2 more formal ISABELLE_BROWSER_INFO;
wenzelm
parents: 53015
diff changeset
   338
  \verb,ISABELLE_BROWSER_INFO,).
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   339
12683
wenzelm
parents: 12681
diff changeset
   340
  \medskip The easiest way to manage Isabelle sessions is via
51057
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   341
  \texttt{isabelle mkroot} (to generate an initial session source
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   342
  setup) and \texttt{isabelle build} (to run sessions as specified in
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   343
  the corresponding \texttt{ROOT} file).  These Isabelle tools are
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   344
  described in further detail in the \emph{Isabelle System Manual}
60270
wenzelm
parents: 59005
diff changeset
   345
  @{cite "isabelle-system"}.
51057
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   346
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   347
  For example, a new session \texttt{MySession} (with document
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   348
  preparation) may be produced as follows:
12683
wenzelm
parents: 12681
diff changeset
   349
wenzelm
parents: 12681
diff changeset
   350
\begin{verbatim}
67042
677cab7c2b85 adapted to changed ROOT syntax (see 13857f49d215);
wenzelm
parents: 61593
diff changeset
   351
  isabelle mkroot MySession
51057
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   352
  isabelle build -D MySession
12683
wenzelm
parents: 12681
diff changeset
   353
\end{verbatim}
wenzelm
parents: 12681
diff changeset
   354
51057
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   355
  The \texttt{isabelle build} job also informs about the file-system
12685
wenzelm
parents: 12683
diff changeset
   356
  location of the ultimate results.  The above dry run should be able
wenzelm
parents: 12683
diff changeset
   357
  to produce some \texttt{document.pdf} (with dummy title, empty table
12743
wenzelm
parents: 12685
diff changeset
   358
  of contents etc.).  Any failure at this stage usually indicates
17183
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   359
  technical problems of the {\LaTeX} installation.
12683
wenzelm
parents: 12681
diff changeset
   360
wenzelm
parents: 12681
diff changeset
   361
  \medskip The detailed arrangement of the session sources is as
12746
wenzelm
parents: 12744
diff changeset
   362
  follows.
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   363
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   364
  \begin{itemize}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   365
12670
wenzelm
parents: 12665
diff changeset
   366
  \item Directory \texttt{MySession} holds the required theory files
wenzelm
parents: 12665
diff changeset
   367
  $T@1$\texttt{.thy}, \dots, $T@n$\texttt{.thy}.
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   368
51057
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   369
  \item File \texttt{MySession/ROOT} specifies the session options and
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   370
  content, with declarations for all wanted theories; it is sufficient
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   371
  to specify the terminal nodes of the theory dependency graph.
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   372
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   373
  \item Directory \texttt{MySession/document} contains everything
12653
wenzelm
parents: 12651
diff changeset
   374
  required for the {\LaTeX} stage; only \texttt{root.tex} needs to be
wenzelm
parents: 12651
diff changeset
   375
  provided initially.
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   376
12653
wenzelm
parents: 12651
diff changeset
   377
  The latter file holds appropriate {\LaTeX} code to commence a
wenzelm
parents: 12651
diff changeset
   378
  document (\verb,\documentclass, etc.), and to include the generated
12743
wenzelm
parents: 12685
diff changeset
   379
  files $T@i$\texttt{.tex} for each theory.  Isabelle will generate a
wenzelm
parents: 12685
diff changeset
   380
  file \texttt{session.tex} holding {\LaTeX} commands to include all
12746
wenzelm
parents: 12744
diff changeset
   381
  generated theory output files in topologically sorted order, so
wenzelm
parents: 12744
diff changeset
   382
  \verb,\input{session}, in the body of \texttt{root.tex} does the job
wenzelm
parents: 12744
diff changeset
   383
  in most situations.
12653
wenzelm
parents: 12651
diff changeset
   384
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   385
  \end{itemize}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   386
51057
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   387
  One may now start to populate the directory \texttt{MySession} and
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   388
  its \texttt{ROOT} file accordingly.  The file
12766
wenzelm
parents: 12764
diff changeset
   389
  \texttt{MySession/document/root.tex} should also be adapted at some
12685
wenzelm
parents: 12683
diff changeset
   390
  point; the default version is mostly self-explanatory.  Note that
wenzelm
parents: 12683
diff changeset
   391
  \verb,\isabellestyle, enables fine-tuning of the general appearance
wenzelm
parents: 12683
diff changeset
   392
  of characters and mathematical symbols (see also
wenzelm
parents: 12683
diff changeset
   393
  \S\ref{sec:doc-prep-symbols}).
12653
wenzelm
parents: 12651
diff changeset
   394
12685
wenzelm
parents: 12683
diff changeset
   395
  Especially observe the included {\LaTeX} packages \texttt{isabelle}
wenzelm
parents: 12683
diff changeset
   396
  (mandatory), \texttt{isabellesym} (required for mathematical
12743
wenzelm
parents: 12685
diff changeset
   397
  symbols), and the final \texttt{pdfsetup} (provides sane defaults
12764
b43333dc6e7d stylistic changes
paulson
parents: 12750
diff changeset
   398
  for \texttt{hyperref}, including URL markup).  All three are
12743
wenzelm
parents: 12685
diff changeset
   399
  distributed with Isabelle. Further packages may be required in
12764
b43333dc6e7d stylistic changes
paulson
parents: 12750
diff changeset
   400
  particular applications, say for unusual mathematical symbols.
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   401
12746
wenzelm
parents: 12744
diff changeset
   402
  \medskip Any additional files for the {\LaTeX} stage go into the
wenzelm
parents: 12744
diff changeset
   403
  \texttt{MySession/document} directory as well.  In particular,
12766
wenzelm
parents: 12764
diff changeset
   404
  adding a file named \texttt{root.bib} causes an automatic run of
wenzelm
parents: 12764
diff changeset
   405
  \texttt{bibtex} to process a bibliographic database; see also
60270
wenzelm
parents: 59005
diff changeset
   406
  \texttt{isabelle document} @{cite "isabelle-system"}.
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   407
12653
wenzelm
parents: 12651
diff changeset
   408
  \medskip Any failure of the document preparation phase in an
12670
wenzelm
parents: 12665
diff changeset
   409
  Isabelle batch session leaves the generated sources in their target
12766
wenzelm
parents: 12764
diff changeset
   410
  location, identified by the accompanying error message.  This lets
wenzelm
parents: 12764
diff changeset
   411
  you trace {\LaTeX} problems with the generated files at hand.
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   412
\<close>
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   413
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   414
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   415
subsection \<open>Structure Markup\<close>
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   416
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   417
text \<open>
12653
wenzelm
parents: 12651
diff changeset
   418
  The large-scale structure of Isabelle documents follows existing
wenzelm
parents: 12651
diff changeset
   419
  {\LaTeX} conventions, with chapters, sections, subsubsections etc.
wenzelm
parents: 12651
diff changeset
   420
  The Isar language includes separate \bfindex{markup commands}, which
12681
wenzelm
parents: 12674
diff changeset
   421
  do not affect the formal meaning of a theory (or proof), but result
12665
wenzelm
parents: 12659
diff changeset
   422
  in corresponding {\LaTeX} elements.
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   423
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   424
  From the Isabelle perspective, each markup command takes a single
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   425
  $text$ argument (delimited by \verb,",~\<open>\<dots>\<close>~\verb,", or
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   426
  \verb,{,\verb,*,~\<open>\<dots>\<close>~\verb,*,\verb,},).  After stripping any
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   427
  surrounding white space, the argument is passed to a {\LaTeX} macro
12766
wenzelm
parents: 12764
diff changeset
   428
  \verb,\isamarkupXYZ, for command \isakeyword{XYZ}.  These macros are
wenzelm
parents: 12764
diff changeset
   429
  defined in \verb,isabelle.sty, according to the meaning given in the
wenzelm
parents: 12764
diff changeset
   430
  rightmost column above.
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   431
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   432
  \medskip The following source fragment illustrates structure markup
12653
wenzelm
parents: 12651
diff changeset
   433
  of a theory.  Note that {\LaTeX} labels may be included inside of
wenzelm
parents: 12651
diff changeset
   434
  section headings as well.
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   435
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   436
  \begin{ttbox}
58869
963fd2084e8f prefer explicit heading command;
wenzelm
parents: 58868
diff changeset
   437
  section {\ttlbrace}* Some properties of Foo Bar elements *{\ttrbrace}
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   438
15136
1275417e3930 Adapted text to new theory header syntax.
nipkow
parents: 14486
diff changeset
   439
  theory Foo_Bar
15141
a95c2ff210ba import -> imports
nipkow
parents: 15136
diff changeset
   440
  imports Main
15136
1275417e3930 Adapted text to new theory header syntax.
nipkow
parents: 14486
diff changeset
   441
  begin
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   442
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   443
  subsection {\ttlbrace}* Basic definitions *{\ttrbrace}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   444
27027
63f0b638355c *** empty log message ***
nipkow
parents: 27015
diff changeset
   445
  definition foo :: \dots
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   446
27027
63f0b638355c *** empty log message ***
nipkow
parents: 27015
diff changeset
   447
  definition bar :: \dots
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   448
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   449
  subsection {\ttlbrace}* Derived rules *{\ttrbrace}
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   450
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   451
  lemma fooI: \dots
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   452
  lemma fooE: \dots
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   453
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   454
  subsection {\ttlbrace}* Main theorem {\ttback}label{\ttlbrace}sec:main-theorem{\ttrbrace} *{\ttrbrace}
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   455
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   456
  theorem main: \dots
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   457
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   458
  end
58869
963fd2084e8f prefer explicit heading command;
wenzelm
parents: 58868
diff changeset
   459
  \end{ttbox}
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   460
\<close>
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   461
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   462
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   463
subsection \<open>Formal Comments and Antiquotations \label{sec:doc-prep-text}\<close>
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   464
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   465
text \<open>
12744
wenzelm
parents: 12743
diff changeset
   466
  Isabelle \bfindex{source comments}, which are of the form
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   467
  \verb,(,\verb,*,~\<open>\<dots>\<close>~\verb,*,\verb,),, essentially act like
12746
wenzelm
parents: 12744
diff changeset
   468
  white space and do not really contribute to the content.  They
wenzelm
parents: 12744
diff changeset
   469
  mainly serve technical purposes to mark certain oddities in the raw
wenzelm
parents: 12744
diff changeset
   470
  input text.  In contrast, \bfindex{formal comments} are portions of
wenzelm
parents: 12744
diff changeset
   471
  text that are associated with formal Isabelle/Isar commands
12681
wenzelm
parents: 12674
diff changeset
   472
  (\bfindex{marginal comments}), or as standalone paragraphs within a
12665
wenzelm
parents: 12659
diff changeset
   473
  theory or proof context (\bfindex{text blocks}).
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   474
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   475
  \medskip Marginal comments are part of each command's concrete
58620
7435b6a3f72e more antiquotations;
wenzelm
parents: 54936
diff changeset
   476
  syntax @{cite "isabelle-isar-ref"}; the common form is ``\verb,--,~$text$''
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   477
  where $text$ is delimited by \verb,",\<open>\<dots>\<close>\verb,", or
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   478
  \verb,{,\verb,*,~\<open>\<dots>\<close>~\verb,*,\verb,}, as before.  Multiple
12670
wenzelm
parents: 12665
diff changeset
   479
  marginal comments may be given at the same time.  Here is a simple
wenzelm
parents: 12665
diff changeset
   480
  example:
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   481
\<close>
12665
wenzelm
parents: 12659
diff changeset
   482
wenzelm
parents: 12659
diff changeset
   483
lemma "A --> A"
67443
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 67406
diff changeset
   484
  \<comment> \<open>a triviality of propositional logic\<close>
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 67406
diff changeset
   485
  \<comment> \<open>(should not really bother)\<close>
3abf6a722518 standardized towards new-style formal comments: isabelle update_comments;
wenzelm
parents: 67406
diff changeset
   486
  by (rule impI) \<comment> \<open>implicit assumption step involved here\<close>
12665
wenzelm
parents: 12659
diff changeset
   487
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   488
text \<open>
12665
wenzelm
parents: 12659
diff changeset
   489
  \noindent The above output has been produced as follows:
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   490
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   491
\begin{verbatim}
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   492
  lemma "A --> A"
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   493
    -- "a triviality of propositional logic"
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   494
    -- "(should not really bother)"
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   495
    by (rule impI) -- "implicit assumption step involved here"
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   496
\end{verbatim}
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   497
12670
wenzelm
parents: 12665
diff changeset
   498
  From the {\LaTeX} viewpoint, ``\verb,--,'' acts like a markup
wenzelm
parents: 12665
diff changeset
   499
  command, associated with the macro \verb,\isamarkupcmt, (taking a
wenzelm
parents: 12665
diff changeset
   500
  single argument).
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   501
12665
wenzelm
parents: 12659
diff changeset
   502
  \medskip Text blocks are introduced by the commands \bfindex{text}
59005
1c54ebc68394 use \isastyletext directly via 'text' command;
wenzelm
parents: 58869
diff changeset
   503
  and \bfindex{txt}. Each takes again a single $text$ argument,
1c54ebc68394 use \isastyletext directly via 'text' command;
wenzelm
parents: 58869
diff changeset
   504
  which is interpreted as a free-form paragraph in {\LaTeX}
1c54ebc68394 use \isastyletext directly via 'text' command;
wenzelm
parents: 58869
diff changeset
   505
  (surrounded by some additional vertical space).  The typesetting
1c54ebc68394 use \isastyletext directly via 'text' command;
wenzelm
parents: 58869
diff changeset
   506
  may be changed by redefining the {\LaTeX} environments of
1c54ebc68394 use \isastyletext directly via 'text' command;
wenzelm
parents: 58869
diff changeset
   507
  \verb,isamarkuptext, or \verb,isamarkuptxt,, respectively
1c54ebc68394 use \isastyletext directly via 'text' command;
wenzelm
parents: 58869
diff changeset
   508
  (via \verb,\renewenvironment,).
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   509
12766
wenzelm
parents: 12764
diff changeset
   510
  \medskip The $text$ part of Isabelle markup commands essentially
wenzelm
parents: 12764
diff changeset
   511
  inserts \emph{quoted material} into a formal text, mainly for
wenzelm
parents: 12764
diff changeset
   512
  instruction of the reader.  An \bfindex{antiquotation} is again a
wenzelm
parents: 12764
diff changeset
   513
  formal object embedded into such an informal portion.  The
wenzelm
parents: 12764
diff changeset
   514
  interpretation of antiquotations is limited to some well-formedness
wenzelm
parents: 12764
diff changeset
   515
  checks, with the result being pretty printed to the resulting
wenzelm
parents: 12764
diff changeset
   516
  document.  Quoted text blocks together with antiquotations provide
wenzelm
parents: 12764
diff changeset
   517
  an attractive means of referring to formal entities, with good
wenzelm
parents: 12764
diff changeset
   518
  confidence in getting the technical details right (especially syntax
wenzelm
parents: 12764
diff changeset
   519
  and types).
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   520
12665
wenzelm
parents: 12659
diff changeset
   521
  The general syntax of antiquotations is as follows:
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   522
  \texttt{{\at}{\ttlbrace}$name$ $arguments${\ttrbrace}}, or
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   523
  \texttt{{\at}{\ttlbrace}$name$ [$options$] $arguments${\ttrbrace}}
12665
wenzelm
parents: 12659
diff changeset
   524
  for a comma-separated list of options consisting of a $name$ or
12766
wenzelm
parents: 12764
diff changeset
   525
  \texttt{$name$=$value$} each.  The syntax of $arguments$ depends on
wenzelm
parents: 12764
diff changeset
   526
  the kind of antiquotation, it generally follows the same conventions
wenzelm
parents: 12764
diff changeset
   527
  for types, terms, or theorems as in the formal part of a theory.
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   528
12766
wenzelm
parents: 12764
diff changeset
   529
  \medskip This sentence demonstrates quotations and antiquotations:
69597
ff784d5a5bfb isabelle update -u control_cartouches;
wenzelm
parents: 69505
diff changeset
   530
  \<^term>\<open>%x y. x\<close> is a well-typed term.
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   531
12764
b43333dc6e7d stylistic changes
paulson
parents: 12750
diff changeset
   532
  \medskip\noindent The output above was produced as follows:
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   533
  \begin{ttbox}
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   534
text {\ttlbrace}*
12764
b43333dc6e7d stylistic changes
paulson
parents: 12750
diff changeset
   535
  This sentence demonstrates quotations and antiquotations:
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   536
  {\at}{\ttlbrace}term "%x y. x"{\ttrbrace} is a well-typed term.
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   537
*{\ttrbrace}
12766
wenzelm
parents: 12764
diff changeset
   538
  \end{ttbox}\vspace{-\medskipamount}
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   539
12764
b43333dc6e7d stylistic changes
paulson
parents: 12750
diff changeset
   540
  The notational change from the ASCII character~\verb,%, to the
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   541
  symbol~\<open>\<lambda>\<close> reveals that Isabelle printed this term, after
12766
wenzelm
parents: 12764
diff changeset
   542
  parsing and type-checking.  Document preparation enables symbolic
wenzelm
parents: 12764
diff changeset
   543
  output by default.
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   544
16523
f8a734dc0fbc *** empty log message ***
nipkow
parents: 16417
diff changeset
   545
  \medskip The next example includes an option to show the type of all
f8a734dc0fbc *** empty log message ***
nipkow
parents: 16417
diff changeset
   546
  variables.  The antiquotation
12766
wenzelm
parents: 12764
diff changeset
   547
  \texttt{{\at}}\verb,{term [show_types] "%x y. x"}, produces the
wenzelm
parents: 12764
diff changeset
   548
  output @{term [show_types] "%x y. x"}.  Type inference has figured
wenzelm
parents: 12764
diff changeset
   549
  out the most general typings in the present theory context.  Terms
wenzelm
parents: 12764
diff changeset
   550
  may acquire different typings due to constraints imposed by their
wenzelm
parents: 12764
diff changeset
   551
  environment; within a proof, for example, variables are given the
wenzelm
parents: 12764
diff changeset
   552
  same types as they have in the main goal statement.
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   553
12764
b43333dc6e7d stylistic changes
paulson
parents: 12750
diff changeset
   554
  \medskip Several further kinds of antiquotations and options are
58620
7435b6a3f72e more antiquotations;
wenzelm
parents: 54936
diff changeset
   555
  available @{cite "isabelle-isar-ref"}.  Here are a few commonly used
12670
wenzelm
parents: 12665
diff changeset
   556
  combinations:
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   557
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   558
  \medskip
12651
930df4604b36 some more ...;
wenzelm
parents: 12648
diff changeset
   559
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   560
  \begin{tabular}{ll}
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   561
  \texttt{\at}\verb,{typ,~$\tau$\verb,}, & print type $\tau$ \\
25338
6eb185959aec updated to notation and abbreviation
nipkow
parents: 22098
diff changeset
   562
  \texttt{\at}\verb,{const,~$c$\verb,}, & check existence of $c$ and print it \\
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   563
  \texttt{\at}\verb,{term,~$t$\verb,}, & print term $t$ \\
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   564
  \texttt{\at}\verb,{prop,~$\phi$\verb,}, & print proposition $\phi$ \\
12665
wenzelm
parents: 12659
diff changeset
   565
  \texttt{\at}\verb,{prop [display],~$\phi$\verb,}, & print large proposition $\phi$ (with linebreaks) \\
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   566
  \texttt{\at}\verb,{prop [source],~$\phi$\verb,}, & check proposition $\phi$, print its input \\
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   567
  \texttt{\at}\verb,{thm,~$a$\verb,}, & print fact $a$ \\
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   568
  \texttt{\at}\verb,{thm,~$a$~\verb,[no_vars]}, & print fact $a$, fixing schematic variables \\
12746
wenzelm
parents: 12744
diff changeset
   569
  \texttt{\at}\verb,{thm [source],~$a$\verb,}, & check availability of fact $a$, print its name \\
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   570
  \texttt{\at}\verb,{text,~$s$\verb,}, & print uninterpreted text $s$ \\
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   571
  \end{tabular}
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   572
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   573
  \medskip
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   574
12665
wenzelm
parents: 12659
diff changeset
   575
  Note that \attrdx{no_vars} given above is \emph{not} an
wenzelm
parents: 12659
diff changeset
   576
  antiquotation option, but an attribute of the theorem argument given
wenzelm
parents: 12659
diff changeset
   577
  here.  This might be useful with a diagnostic command like
wenzelm
parents: 12659
diff changeset
   578
  \isakeyword{thm}, too.
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   579
12665
wenzelm
parents: 12659
diff changeset
   580
  \medskip The \texttt{\at}\verb,{text, $s$\verb,}, antiquotation is
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   581
  particularly interesting.  Embedding uninterpreted text within an
12665
wenzelm
parents: 12659
diff changeset
   582
  informal body might appear useless at first sight.  Here the key
wenzelm
parents: 12659
diff changeset
   583
  virtue is that the string $s$ is processed as Isabelle output,
wenzelm
parents: 12659
diff changeset
   584
  interpreting Isabelle symbols appropriately.
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   585
69505
cc2d676d5395 isabelle update_cartouches -t;
wenzelm
parents: 67443
diff changeset
   586
  For example, \texttt{\at}\verb,{text "\<forall>\<exists>"}, produces \<open>\<forall>\<exists>\<close>, according to the standard interpretation of these symbol
12665
wenzelm
parents: 12659
diff changeset
   587
  (cf.\ \S\ref{sec:doc-prep-symbols}).  Thus we achieve consistent
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   588
  mathematical notation in both the formal and informal parts of the
12766
wenzelm
parents: 12764
diff changeset
   589
  document very easily, independently of the term language of
wenzelm
parents: 12764
diff changeset
   590
  Isabelle.  Manual {\LaTeX} code would leave more control over the
wenzelm
parents: 12764
diff changeset
   591
  typesetting, but is also slightly more tedious.
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   592
\<close>
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   593
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   594
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   595
subsection \<open>Interpretation of Symbols \label{sec:doc-prep-symbols}\<close>
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   596
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   597
text \<open>
12665
wenzelm
parents: 12659
diff changeset
   598
  As has been pointed out before (\S\ref{sec:syntax-symbols}),
12670
wenzelm
parents: 12665
diff changeset
   599
  Isabelle symbols are the smallest syntactic entities --- a
12681
wenzelm
parents: 12674
diff changeset
   600
  straightforward generalization of ASCII characters.  While Isabelle
12665
wenzelm
parents: 12659
diff changeset
   601
  does not impose any interpretation of the infinite collection of
12764
b43333dc6e7d stylistic changes
paulson
parents: 12750
diff changeset
   602
  named symbols, {\LaTeX} documents use canonical glyphs for certain
58620
7435b6a3f72e more antiquotations;
wenzelm
parents: 54936
diff changeset
   603
  standard symbols @{cite "isabelle-isar-ref"}.
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   604
12766
wenzelm
parents: 12764
diff changeset
   605
  The {\LaTeX} code produced from Isabelle text follows a simple
wenzelm
parents: 12764
diff changeset
   606
  scheme.  You can tune the final appearance by redefining certain
wenzelm
parents: 12764
diff changeset
   607
  macros, say in \texttt{root.tex} of the document.
12670
wenzelm
parents: 12665
diff changeset
   608
wenzelm
parents: 12665
diff changeset
   609
  \begin{enumerate}
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   610
12670
wenzelm
parents: 12665
diff changeset
   611
  \item 7-bit ASCII characters: letters \texttt{A\dots Z} and
12746
wenzelm
parents: 12744
diff changeset
   612
  \texttt{a\dots z} are output directly, digits are passed as an
12670
wenzelm
parents: 12665
diff changeset
   613
  argument to the \verb,\isadigit, macro, other characters are
wenzelm
parents: 12665
diff changeset
   614
  replaced by specifically named macros of the form
12665
wenzelm
parents: 12659
diff changeset
   615
  \verb,\isacharXYZ,.
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   616
12766
wenzelm
parents: 12764
diff changeset
   617
  \item Named symbols: \verb,\,\verb,<XYZ>, is turned into
wenzelm
parents: 12764
diff changeset
   618
  \verb,{\isasymXYZ},; note the additional braces.
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   619
12766
wenzelm
parents: 12764
diff changeset
   620
  \item Named control symbols: \verb,\,\verb,<^XYZ>, is turned into
wenzelm
parents: 12764
diff changeset
   621
  \verb,\isactrlXYZ,; subsequent symbols may act as arguments if the
wenzelm
parents: 12764
diff changeset
   622
  control macro is defined accordingly.
12670
wenzelm
parents: 12665
diff changeset
   623
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   624
  \end{enumerate}
12665
wenzelm
parents: 12659
diff changeset
   625
12764
b43333dc6e7d stylistic changes
paulson
parents: 12750
diff changeset
   626
  You may occasionally wish to give new {\LaTeX} interpretations of
b43333dc6e7d stylistic changes
paulson
parents: 12750
diff changeset
   627
  named symbols.  This merely requires an appropriate definition of
12766
wenzelm
parents: 12764
diff changeset
   628
  \verb,\isasymXYZ,, for \verb,\,\verb,<XYZ>, (see
12746
wenzelm
parents: 12744
diff changeset
   629
  \texttt{isabelle.sty} for working examples).  Control symbols are
wenzelm
parents: 12744
diff changeset
   630
  slightly more difficult to get right, though.
12665
wenzelm
parents: 12659
diff changeset
   631
wenzelm
parents: 12659
diff changeset
   632
  \medskip The \verb,\isabellestyle, macro provides a high-level
wenzelm
parents: 12659
diff changeset
   633
  interface to tune the general appearance of individual symbols.  For
12670
wenzelm
parents: 12665
diff changeset
   634
  example, \verb,\isabellestyle{it}, uses the italics text style to
wenzelm
parents: 12665
diff changeset
   635
  mimic the general appearance of the {\LaTeX} math mode; double
12743
wenzelm
parents: 12685
diff changeset
   636
  quotes are not printed at all.  The resulting quality of typesetting
wenzelm
parents: 12685
diff changeset
   637
  is quite good, so this should be the default style for work that
wenzelm
parents: 12685
diff changeset
   638
  gets distributed to a broader audience.
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   639
\<close>
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   640
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   641
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   642
subsection \<open>Suppressing Output \label{sec:doc-prep-suppress}\<close>
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   643
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   644
text \<open>
12748
wenzelm
parents: 12746
diff changeset
   645
  By default, Isabelle's document system generates a {\LaTeX} file for
wenzelm
parents: 12746
diff changeset
   646
  each theory that gets loaded while running the session.  The
wenzelm
parents: 12746
diff changeset
   647
  generated \texttt{session.tex} will include all of these in order of
wenzelm
parents: 12746
diff changeset
   648
  appearance, which in turn gets included by the standard
12743
wenzelm
parents: 12685
diff changeset
   649
  \texttt{root.tex}.  Certainly one may change the order or suppress
12746
wenzelm
parents: 12744
diff changeset
   650
  unwanted theories by ignoring \texttt{session.tex} and load
wenzelm
parents: 12744
diff changeset
   651
  individual files directly in \texttt{root.tex}.  On the other hand,
wenzelm
parents: 12744
diff changeset
   652
  such an arrangement requires additional maintenance whenever the
wenzelm
parents: 12744
diff changeset
   653
  collection of theories changes.
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   654
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   655
  Alternatively, one may tune the theory loading process in
51057
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   656
  \texttt{ROOT} itself: some sequential order of \textbf{theories}
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   657
  sections may enforce a certain traversal of the dependency graph,
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   658
  although this could degrade parallel processing.  The nodes of each
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   659
  sub-graph that is specified here are presented in some topological
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   660
  order of their formal dependencies.
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   661
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   662
  Moreover, the system build option \verb,document=false, allows to
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   663
  disable document generation for some theories.  Its usage in the
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   664
  session \texttt{ROOT} is like this:
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   665
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   666
\begin{verbatim}
51057
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   667
  theories [document = false] T
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   668
\end{verbatim}
12645
3af5de958a1a some text on document preparation;
wenzelm
parents: 12642
diff changeset
   669
17183
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   670
  \medskip Theory output may be suppressed more selectively, either
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   671
  via \bfindex{tagged command regions} or \bfindex{ignored material}.
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   672
17183
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   673
  Tagged command regions works by annotating commands with named tags,
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   674
  which correspond to certain {\LaTeX} markup that tells how to treat
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   675
  particular parts of a document when doing the actual type-setting.
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   676
  By default, certain Isabelle/Isar commands are implicitly marked up
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   677
  using the predefined tags ``\emph{theory}'' (for theory begin and
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   678
  end), ``\emph{proof}'' (for proof commands), and ``\emph{ML}'' (for
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   679
  commands involving ML code).  Users may add their own tags using the
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   680
  \verb,%,\emph{tag} notation right after a command name.  In the
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   681
  subsequent example we hide a particularly irrelevant proof:
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   682
\<close>
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   683
17183
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   684
lemma "x = x" by %invisible (simp)
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   685
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   686
text \<open>
17183
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   687
  The original source has been ``\verb,lemma "x = x" by %invisible (simp),''.
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   688
  Tags observe the structure of proofs; adjacent commands with the
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   689
  same tag are joined into a single region.  The Isabelle document
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   690
  preparation system allows the user to specify how to interpret a
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   691
  tagged region, in order to keep, drop, or fold the corresponding
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   692
  parts of the document.  See the \emph{Isabelle System Manual}
60270
wenzelm
parents: 59005
diff changeset
   693
  @{cite "isabelle-system"} for further details, especially on
51057
a22b134f862e updated explanations of document preparation;
wenzelm
parents: 50069
diff changeset
   694
  \texttt{isabelle build} and \texttt{isabelle document}.
12648
16d4b8c09086 some more text;
wenzelm
parents: 12645
diff changeset
   695
17183
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   696
  Ignored material is specified by delimiting the original formal
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   697
  source with special source comments
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   698
  \verb,(,\verb,*,\verb,<,\verb,*,\verb,), and
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   699
  \verb,(,\verb,*,\verb,>,\verb,*,\verb,),.  These parts are stripped
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   700
  before the type-setting phase, without affecting the formal checking
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   701
  of the theory, of course.  For example, we may hide parts of a proof
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   702
  that seem unfit for general public inspection.  The following
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   703
  ``fully automatic'' proof is actually a fake:
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   704
\<close>
12651
930df4604b36 some more ...;
wenzelm
parents: 12648
diff changeset
   705
930df4604b36 some more ...;
wenzelm
parents: 12648
diff changeset
   706
lemma "x \<noteq> (0::int) \<Longrightarrow> 0 < x * x"
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 13439
diff changeset
   707
  by (auto(*<*)simp add: zero_less_mult_iff(*>*))
12651
930df4604b36 some more ...;
wenzelm
parents: 12648
diff changeset
   708
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   709
text \<open>
17183
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   710
  \noindent The real source of the proof has been as follows:
12651
930df4604b36 some more ...;
wenzelm
parents: 12648
diff changeset
   711
930df4604b36 some more ...;
wenzelm
parents: 12648
diff changeset
   712
\begin{verbatim}
14353
79f9fbef9106 Added lemmas to Ring_and_Field with slightly modified simplification rules
paulson
parents: 13439
diff changeset
   713
  by (auto(*<*)simp add: zero_less_mult_iff(*>*))
12659
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   714
\end{verbatim}
2aa05eb15bd2 getting close to completion;
wenzelm
parents: 12653
diff changeset
   715
%(*
12651
930df4604b36 some more ...;
wenzelm
parents: 12648
diff changeset
   716
12766
wenzelm
parents: 12764
diff changeset
   717
  \medskip Suppressing portions of printed text demands care.  You
wenzelm
parents: 12764
diff changeset
   718
  should not misrepresent the underlying theory development.  It is
wenzelm
parents: 12764
diff changeset
   719
  easy to invalidate the visible text by hiding references to
17183
a788a05fb81b cover tagged command regions;
wenzelm
parents: 16523
diff changeset
   720
  questionable axioms, for example.
67406
23307fd33906 isabelle update_cartouches -c;
wenzelm
parents: 67398
diff changeset
   721
\<close>
12629
281aa36829d8 beginnings of concrete syntax;
wenzelm
parents: 11647
diff changeset
   722
11647
0538cb0f7999 initial setup for chapter on document preparation;
wenzelm
parents:
diff changeset
   723
(*<*)
0538cb0f7999 initial setup for chapter on document preparation;
wenzelm
parents:
diff changeset
   724
end
0538cb0f7999 initial setup for chapter on document preparation;
wenzelm
parents:
diff changeset
   725
(*>*)