src/Doc/Isar_Ref/Outer_Syntax.thy
author wenzelm
Thu, 05 Nov 2015 00:02:30 +0100
changeset 61579 634cd44bb1d3
parent 61503 28e788ca2c5d
child 61656 cfabbc083977
permissions -rw-r--r--
symbolic syntax "\<comment> text";
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
     1
theory Outer_Syntax
42651
e3fdb7c96be5 formal Base theory;
wenzelm
parents: 42596
diff changeset
     2
imports Base Main
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
     3
begin
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
     4
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
     5
chapter \<open>Outer syntax --- the theory language \label{ch:outer-syntax}\<close>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
     6
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
     7
text \<open>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
     8
  The rather generic framework of Isabelle/Isar syntax emerges from
61477
e467ae7aa808 more control symbols;
wenzelm
parents: 61473
diff changeset
     9
  three main syntactic categories: \<^emph>\<open>commands\<close> of the top-level
e467ae7aa808 more control symbols;
wenzelm
parents: 61473
diff changeset
    10
  Isar engine (covering theory and proof elements), \<^emph>\<open>methods\<close> for
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    11
  general goal refinements (analogous to traditional ``tactics''), and
61477
e467ae7aa808 more control symbols;
wenzelm
parents: 61473
diff changeset
    12
  \<^emph>\<open>attributes\<close> for operations on facts (within a certain
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    13
  context).  Subsequently we give a reference of basic syntactic
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    14
  entities underlying Isabelle/Isar syntax in a bottom-up manner.
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    15
  Concrete theory and proof language elements will be introduced later
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    16
  on.
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    17
61421
e0825405d398 more symbols;
wenzelm
parents: 61252
diff changeset
    18
  \<^medskip>
e0825405d398 more symbols;
wenzelm
parents: 61252
diff changeset
    19
  In order to get started with writing well-formed
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    20
  Isabelle/Isar documents, the most important aspect to be noted is
61477
e467ae7aa808 more control symbols;
wenzelm
parents: 61473
diff changeset
    21
  the difference of \<^emph>\<open>inner\<close> versus \<^emph>\<open>outer\<close> syntax.  Inner
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    22
  syntax is that of Isabelle types and terms of the logic, while outer
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    23
  syntax is that of Isabelle/Isar theory sources (specifications and
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    24
  proofs).  As a general rule, inner syntax entities may occur only as
61477
e467ae7aa808 more control symbols;
wenzelm
parents: 61473
diff changeset
    25
  \<^emph>\<open>atomic entities\<close> within outer syntax.  For example, the string
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
    26
  \<^verbatim>\<open>"x + y"\<close> and identifier \<^verbatim>\<open>z\<close> are legal term
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
    27
  specifications within a theory, while \<^verbatim>\<open>x + y\<close> without
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    28
  quotes is not.
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    29
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    30
  Printed theory documents usually omit quotes to gain readability
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
    31
  (this is a matter of {\LaTeX} macro setup, say via \<^verbatim>\<open>\isabellestyle\<close>,
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
    32
  see also @{cite "isabelle-system"}).  Experienced
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    33
  users of Isabelle/Isar may easily reconstruct the lost technical
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    34
  information, while mere readers need not care about quotes at all.
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
    35
\<close>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    36
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    37
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
    38
section \<open>Commands\<close>
50213
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 48985
diff changeset
    39
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
    40
text \<open>
50213
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 48985
diff changeset
    41
  \begin{matharray}{rcl}
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
    42
    @{command_def "print_commands"}\<open>\<^sup>*\<close> & : & \<open>any \<rightarrow>\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
    43
    @{command_def "help"}\<open>\<^sup>*\<close> & : & \<open>any \<rightarrow>\<close> \\
50213
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 48985
diff changeset
    44
  \end{matharray}
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 48985
diff changeset
    45
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
    46
  @{rail \<open>
50213
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 48985
diff changeset
    47
    @@{command help} (@{syntax name} * )
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
    48
  \<close>}
50213
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 48985
diff changeset
    49
61439
2bf52eec4e8a more symbols;
wenzelm
parents: 61421
diff changeset
    50
  \<^descr> @{command "print_commands"} prints all outer syntax keywords
50213
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 48985
diff changeset
    51
  and commands.
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 48985
diff changeset
    52
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
    53
  \<^descr> @{command "help"}~\<open>pats\<close> retrieves outer syntax
50213
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 48985
diff changeset
    54
  commands according to the specified name patterns.
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
    55
\<close>
50213
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 48985
diff changeset
    56
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 48985
diff changeset
    57
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
    58
subsubsection \<open>Examples\<close>
50213
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 48985
diff changeset
    59
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
    60
text \<open>Some common diagnostic commands are retrieved like this
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
    61
  (according to usual naming conventions):\<close>
50213
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 48985
diff changeset
    62
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 48985
diff changeset
    63
help "print"
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 48985
diff changeset
    64
help "find"
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 48985
diff changeset
    65
7b73c0509835 refined outer syntax 'help' command;
wenzelm
parents: 48985
diff changeset
    66
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
    67
section \<open>Lexical matters \label{sec:outer-lex}\<close>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    68
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
    69
text \<open>The outer lexical syntax consists of three main categories of
28776
e4090e51b8b9 misc tuning;
wenzelm
parents: 28775
diff changeset
    70
  syntax tokens:
28775
d25fe9601dbd tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents: 28774
diff changeset
    71
61477
e467ae7aa808 more control symbols;
wenzelm
parents: 61473
diff changeset
    72
  \<^enum> \<^emph>\<open>major keywords\<close> --- the command names that are available
28775
d25fe9601dbd tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents: 28774
diff changeset
    73
  in the present logic session;
d25fe9601dbd tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents: 28774
diff changeset
    74
61477
e467ae7aa808 more control symbols;
wenzelm
parents: 61473
diff changeset
    75
  \<^enum> \<^emph>\<open>minor keywords\<close> --- additional literal tokens required
28775
d25fe9601dbd tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents: 28774
diff changeset
    76
  by the syntax of commands;
d25fe9601dbd tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents: 28774
diff changeset
    77
61477
e467ae7aa808 more control symbols;
wenzelm
parents: 61473
diff changeset
    78
  \<^enum> \<^emph>\<open>named tokens\<close> --- various categories of identifiers etc.
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
    79
28775
d25fe9601dbd tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents: 28774
diff changeset
    80
28776
e4090e51b8b9 misc tuning;
wenzelm
parents: 28775
diff changeset
    81
  Major keywords and minor keywords are guaranteed to be disjoint.
28775
d25fe9601dbd tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents: 28774
diff changeset
    82
  This helps user-interfaces to determine the overall structure of a
d25fe9601dbd tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents: 28774
diff changeset
    83
  theory text, without knowing the full details of command syntax.
28776
e4090e51b8b9 misc tuning;
wenzelm
parents: 28775
diff changeset
    84
  Internally, there is some additional information about the kind of
e4090e51b8b9 misc tuning;
wenzelm
parents: 28775
diff changeset
    85
  major keywords, which approximates the command type (theory command,
e4090e51b8b9 misc tuning;
wenzelm
parents: 28775
diff changeset
    86
  proof command etc.).
28775
d25fe9601dbd tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents: 28774
diff changeset
    87
d25fe9601dbd tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents: 28774
diff changeset
    88
  Keywords override named tokens.  For example, the presence of a
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
    89
  command called \<^verbatim>\<open>term\<close> inhibits the identifier \<^verbatim>\<open>term\<close>, but the
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
    90
  string \<^verbatim>\<open>"term"\<close> can be used instead.
28775
d25fe9601dbd tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents: 28774
diff changeset
    91
  By convention, the outer syntax always allows quoted strings in
d25fe9601dbd tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents: 28774
diff changeset
    92
  addition to identifiers, wherever a named entity is expected.
d25fe9601dbd tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents: 28774
diff changeset
    93
28776
e4090e51b8b9 misc tuning;
wenzelm
parents: 28775
diff changeset
    94
  When tokenizing a given input sequence, the lexer repeatedly takes
e4090e51b8b9 misc tuning;
wenzelm
parents: 28775
diff changeset
    95
  the longest prefix of the input that forms a valid token.  Spaces,
e4090e51b8b9 misc tuning;
wenzelm
parents: 28775
diff changeset
    96
  tabs, newlines and formfeeds between tokens serve as explicit
e4090e51b8b9 misc tuning;
wenzelm
parents: 28775
diff changeset
    97
  separators.
e4090e51b8b9 misc tuning;
wenzelm
parents: 28775
diff changeset
    98
61421
e0825405d398 more symbols;
wenzelm
parents: 61252
diff changeset
    99
  \<^medskip>
e0825405d398 more symbols;
wenzelm
parents: 61252
diff changeset
   100
  The categories for named tokens are defined once and for all as follows.
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   101
28776
e4090e51b8b9 misc tuning;
wenzelm
parents: 28775
diff changeset
   102
  \begin{center}
28775
d25fe9601dbd tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents: 28774
diff changeset
   103
  \begin{supertabular}{rcl}
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   104
    @{syntax_def ident} & = & \<open>letter (subscript\<^sup>? quasiletter)\<^sup>*\<close> \\
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   105
    @{syntax_def longident} & = & \<open>ident(\<close>\<^verbatim>\<open>.\<close>\<open>ident)\<^sup>+\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   106
    @{syntax_def symident} & = & \<open>sym\<^sup>+  |\<close>~~\<^verbatim>\<open>\\<close>\<^verbatim>\<open><\<close>\<open>ident\<close>\<^verbatim>\<open>>\<close> \\
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   107
    @{syntax_def nat} & = & \<open>digit\<^sup>+\<close> \\
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   108
    @{syntax_def float} & = & @{syntax_ref nat}\<^verbatim>\<open>.\<close>@{syntax_ref nat}~~\<open>|\<close>~~\<^verbatim>\<open>-\<close>@{syntax_ref nat}\<^verbatim>\<open>.\<close>@{syntax_ref nat} \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   109
    @{syntax_def var} & = & \<^verbatim>\<open>?\<close>\<open>ident  |\<close>~~\<^verbatim>\<open>?\<close>\<open>ident\<close>\<^verbatim>\<open>.\<close>\<open>nat\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   110
    @{syntax_def typefree} & = & \<^verbatim>\<open>'\<close>\<open>ident\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   111
    @{syntax_def typevar} & = & \<^verbatim>\<open>?\<close>\<open>typefree  |\<close>~~\<^verbatim>\<open>?\<close>\<open>typefree\<close>\<^verbatim>\<open>.\<close>\<open>nat\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   112
    @{syntax_def string} & = & \<^verbatim>\<open>"\<close> \<open>\<dots>\<close> \<^verbatim>\<open>"\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   113
    @{syntax_def altstring} & = & \<^verbatim>\<open>`\<close> \<open>\<dots>\<close> \<^verbatim>\<open>`\<close> \\
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   114
    @{syntax_def cartouche} & = & @{verbatim "\<open>"} \<open>\<dots>\<close> @{verbatim "\<close>"} \\
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   115
    @{syntax_def verbatim} & = & \<^verbatim>\<open>{*\<close> \<open>\<dots>\<close> \<^verbatim>\<open>*}\<close> \\[1ex]
28775
d25fe9601dbd tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents: 28774
diff changeset
   116
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   117
    \<open>letter\<close> & = & \<open>latin  |\<close>~~\<^verbatim>\<open>\\<close>\<^verbatim>\<open><\<close>\<open>latin\<close>\<^verbatim>\<open>>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\\<close>\<^verbatim>\<open><\<close>\<open>latin latin\<close>\<^verbatim>\<open>>\<close>~~\<open>|  greek  |\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   118
    \<open>subscript\<close> & = & \<^verbatim>\<open>\<^sub>\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   119
    \<open>quasiletter\<close> & = & \<open>letter  |  digit  |\<close>~~\<^verbatim>\<open>_\<close>~~\<open>|\<close>~~\<^verbatim>\<open>'\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   120
    \<open>latin\<close> & = & \<^verbatim>\<open>a\<close>~~\<open>| \<dots> |\<close>~~\<^verbatim>\<open>z\<close>~~\<open>|\<close>~~\<^verbatim>\<open>A\<close>~~\<open>|  \<dots> |\<close>~~\<^verbatim>\<open>Z\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   121
    \<open>digit\<close> & = & \<^verbatim>\<open>0\<close>~~\<open>|  \<dots> |\<close>~~\<^verbatim>\<open>9\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   122
    \<open>sym\<close> & = & \<^verbatim>\<open>!\<close>~~\<open>|\<close>~~\<^verbatim>\<open>#\<close>~~\<open>|\<close>~~\<^verbatim>\<open>$\<close>~~\<open>|\<close>~~\<^verbatim>\<open>%\<close>~~\<open>|\<close>~~\<^verbatim>\<open>&\<close>~~\<open>|\<close>~~\<^verbatim>\<open>*\<close>~~\<open>|\<close>~~\<^verbatim>\<open>+\<close>~~\<open>|\<close>~~\<^verbatim>\<open>-\<close>~~\<open>|\<close>~~\<^verbatim>\<open>/\<close>~~\<open>|\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   123
    & & \<^verbatim>\<open><\<close>~~\<open>|\<close>~~\<^verbatim>\<open>=\<close>~~\<open>|\<close>~~\<^verbatim>\<open>>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>?\<close>~~\<open>|\<close>~~\<^verbatim>\<open>@\<close>~~\<open>|\<close>~~\<^verbatim>\<open>^\<close>~~\<open>|\<close>~~\<^verbatim>\<open>_\<close>~~\<open>|\<close>~~\<^verbatim>\<open>|\<close>~~\<open>|\<close>~~\<^verbatim>\<open>~\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   124
    \<open>greek\<close> & = & \<^verbatim>\<open>\<alpha>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<beta>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<gamma>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<delta>\<close>~~\<open>|\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   125
          &   & \<^verbatim>\<open>\<epsilon>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<zeta>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<eta>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<theta>\<close>~~\<open>|\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   126
          &   & \<^verbatim>\<open>\<iota>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<kappa>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<mu>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<nu>\<close>~~\<open>|\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   127
          &   & \<^verbatim>\<open>\<xi>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<pi>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<rho>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<sigma>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<tau>\<close>~~\<open>|\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   128
          &   & \<^verbatim>\<open>\<upsilon>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<phi>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<chi>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<psi>\<close>~~\<open>|\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   129
          &   & \<^verbatim>\<open>\<omega>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<Gamma>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<Delta>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<Theta>\<close>~~\<open>|\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   130
          &   & \<^verbatim>\<open>\<Lambda>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<Xi>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<Pi>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<Sigma>\<close>~~\<open>|\<close> \\
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   131
          &   & \<^verbatim>\<open>\<Upsilon>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<Phi>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<Psi>\<close>~~\<open>|\<close>~~\<^verbatim>\<open>\<Omega>\<close> \\
28775
d25fe9601dbd tuned outer lexical syntax; fixed var/tvar: really need question marks here;
wenzelm
parents: 28774
diff changeset
   132
  \end{supertabular}
28776
e4090e51b8b9 misc tuning;
wenzelm
parents: 28775
diff changeset
   133
  \end{center}
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   134
28778
a25630deacaf misc tuning of inner syntax;
wenzelm
parents: 28776
diff changeset
   135
  A @{syntax_ref var} or @{syntax_ref typevar} describes an unknown,
a25630deacaf misc tuning of inner syntax;
wenzelm
parents: 28776
diff changeset
   136
  which is internally a pair of base name and index (ML type @{ML_type
a25630deacaf misc tuning of inner syntax;
wenzelm
parents: 28776
diff changeset
   137
  indexname}).  These components are either separated by a dot as in
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   138
  \<open>?x.1\<close> or \<open>?x7.3\<close> or run together as in \<open>?x1\<close>.  The latter form is possible
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   139
  if the base name does not end with digits.  If the index is 0, it may be
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   140
  dropped altogether: \<open>?x\<close> and \<open>?x0\<close> and \<open>?x.0\<close> all refer to the
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   141
  same unknown, with basename \<open>x\<close> and index 0.
28778
a25630deacaf misc tuning of inner syntax;
wenzelm
parents: 28776
diff changeset
   142
a25630deacaf misc tuning of inner syntax;
wenzelm
parents: 28776
diff changeset
   143
  The syntax of @{syntax_ref string} admits any characters, including
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   144
  newlines; ``\<^verbatim>\<open>"\<close>'' (double-quote) and ``\<^verbatim>\<open>\\<close>''
58724
e5f809f52f26 more antiquotations;
wenzelm
parents: 58618
diff changeset
   145
  (backslash) need to be escaped by a backslash; arbitrary
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   146
  character codes may be specified as ``\<^verbatim>\<open>\\<close>\<open>ddd\<close>'',
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   147
  with three decimal digits.  Alternative strings according to
28778
a25630deacaf misc tuning of inner syntax;
wenzelm
parents: 28776
diff changeset
   148
  @{syntax_ref altstring} are analogous, using single back-quotes
a25630deacaf misc tuning of inner syntax;
wenzelm
parents: 28776
diff changeset
   149
  instead.
a25630deacaf misc tuning of inner syntax;
wenzelm
parents: 28776
diff changeset
   150
58725
9402a7f15ed5 tuned exposition of {* ... *};
wenzelm
parents: 58724
diff changeset
   151
  The body of @{syntax_ref verbatim} may consist of any text not containing
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   152
  ``\<^verbatim>\<open>*}\<close>''; this allows to include quotes without further
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   153
  escapes, but there is no way to escape ``\<^verbatim>\<open>*}\<close>''. Cartouches
58725
9402a7f15ed5 tuned exposition of {* ... *};
wenzelm
parents: 58724
diff changeset
   154
  do not have this limitation.
28778
a25630deacaf misc tuning of inner syntax;
wenzelm
parents: 28776
diff changeset
   155
55033
8e8243975860 support for nested text cartouches;
wenzelm
parents: 53059
diff changeset
   156
  A @{syntax_ref cartouche} consists of arbitrary text, with properly
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   157
  balanced blocks of ``@{verbatim "\<open>"}~\<open>\<dots>\<close>~@{verbatim
55033
8e8243975860 support for nested text cartouches;
wenzelm
parents: 53059
diff changeset
   158
  "\<close>"}''.  Note that the rendering of cartouche delimiters is
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   159
  usually like this: ``\<open>\<open> \<dots> \<close>\<close>''.
55033
8e8243975860 support for nested text cartouches;
wenzelm
parents: 53059
diff changeset
   160
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   161
  Source comments take the form \<^verbatim>\<open>(*\<close>~\<open>\<dots>\<close>~\<^verbatim>\<open>*)\<close> and may be nested, although the user-interface
28778
a25630deacaf misc tuning of inner syntax;
wenzelm
parents: 28776
diff changeset
   162
  might prevent this.  Note that this form indicates source comments
a25630deacaf misc tuning of inner syntax;
wenzelm
parents: 28776
diff changeset
   163
  only, which are stripped after lexical analysis of the input.  The
61477
e467ae7aa808 more control symbols;
wenzelm
parents: 61473
diff changeset
   164
  Isar syntax also provides proper \<^emph>\<open>document comments\<close> that are
28778
a25630deacaf misc tuning of inner syntax;
wenzelm
parents: 28776
diff changeset
   165
  considered as part of the text (see \secref{sec:comments}).
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   166
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   167
  Common mathematical symbols such as \<open>\<forall>\<close> are represented in
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   168
  Isabelle as \<^verbatim>\<open>\<forall>\<close>.  There are infinitely many Isabelle
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   169
  symbols like this, although proper presentation is left to front-end
58842
22b87ab47d3b discontinued Proof General;
wenzelm
parents: 58725
diff changeset
   170
  tools such as {\LaTeX} or Isabelle/jEdit.  A list of
47822
34b44d28fc4b some updates concerning current Proof General 4.x, which lacks X-Symbol mode of 3.x;
wenzelm
parents: 47114
diff changeset
   171
  predefined Isabelle symbols that work well with these tools is given
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   172
  in \appref{app:symbols}.  Note that \<^verbatim>\<open>\<lambda>\<close> does not belong
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   173
  to the \<open>letter\<close> category, since it is already used differently
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   174
  in the Pure term language.\<close>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   175
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   176
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   177
section \<open>Common syntax entities\<close>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   178
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   179
text \<open>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   180
  We now introduce several basic syntactic entities, such as names,
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   181
  terms, and theorem specifications, which are factored out of the
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   182
  actual Isar language elements to be described later.
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   183
\<close>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   184
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   185
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   186
subsection \<open>Names\<close>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   187
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   188
text \<open>Entity @{syntax name} usually refers to any name of types,
61477
e467ae7aa808 more control symbols;
wenzelm
parents: 61473
diff changeset
   189
  constants, theorems etc.\ that are to be \<^emph>\<open>declared\<close> or
e467ae7aa808 more control symbols;
wenzelm
parents: 61473
diff changeset
   190
  \<^emph>\<open>defined\<close> (so qualified identifiers are excluded here).  Quoted
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   191
  strings provide an escape for non-identifier names or those ruled
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   192
  out by outer syntax keywords (e.g.\ quoted \<^verbatim>\<open>"let"\<close>).
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   193
  Already existing objects are usually referenced by @{syntax
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   194
  nameref}.
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   195
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   196
  @{rail \<open>
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   197
    @{syntax_def name}: @{syntax ident} | @{syntax symident} |
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   198
      @{syntax string} | @{syntax nat}
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   199
    ;
60131
wenzelm
parents: 59853
diff changeset
   200
    @{syntax_def par_name}: '(' @{syntax name} ')'
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   201
    ;
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   202
    @{syntax_def nameref}: @{syntax name} | @{syntax longident}
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   203
  \<close>}
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   204
\<close>
40296
ac4d75f86d97 syntax category "real" subsumes plain "int";
wenzelm
parents: 40291
diff changeset
   205
ac4d75f86d97 syntax category "real" subsumes plain "int";
wenzelm
parents: 40291
diff changeset
   206
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   207
subsection \<open>Numbers\<close>
40296
ac4d75f86d97 syntax category "real" subsumes plain "int";
wenzelm
parents: 40291
diff changeset
   208
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   209
text \<open>The outer lexical syntax (\secref{sec:outer-lex}) admits
40296
ac4d75f86d97 syntax category "real" subsumes plain "int";
wenzelm
parents: 40291
diff changeset
   210
  natural numbers and floating point numbers.  These are combined as
ac4d75f86d97 syntax category "real" subsumes plain "int";
wenzelm
parents: 40291
diff changeset
   211
  @{syntax int} and @{syntax real} as follows.
ac4d75f86d97 syntax category "real" subsumes plain "int";
wenzelm
parents: 40291
diff changeset
   212
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   213
  @{rail \<open>
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   214
    @{syntax_def int}: @{syntax nat} | '-' @{syntax nat}
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   215
    ;
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   216
    @{syntax_def real}: @{syntax float} | @{syntax int}
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   217
  \<close>}
40296
ac4d75f86d97 syntax category "real" subsumes plain "int";
wenzelm
parents: 40291
diff changeset
   218
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   219
  Note that there is an overlap with the category @{syntax name},
40296
ac4d75f86d97 syntax category "real" subsumes plain "int";
wenzelm
parents: 40291
diff changeset
   220
  which also includes @{syntax nat}.
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   221
\<close>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   222
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   223
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   224
subsection \<open>Comments \label{sec:comments}\<close>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   225
61579
634cd44bb1d3 symbolic syntax "\<comment> text";
wenzelm
parents: 61503
diff changeset
   226
text \<open>
634cd44bb1d3 symbolic syntax "\<comment> text";
wenzelm
parents: 61503
diff changeset
   227
  Large chunks of plain @{syntax text} are usually given @{syntax verbatim},
634cd44bb1d3 symbolic syntax "\<comment> text";
wenzelm
parents: 61503
diff changeset
   228
  i.e.\ enclosed in \<^verbatim>\<open>{*\<close>~\<open>\<dots>\<close>~\<^verbatim>\<open>*}\<close>, or as @{syntax cartouche} \<open>\<open>\<dots>\<close>\<close>. For
634cd44bb1d3 symbolic syntax "\<comment> text";
wenzelm
parents: 61503
diff changeset
   229
  convenience, any of the smaller text units conforming to @{syntax nameref}
634cd44bb1d3 symbolic syntax "\<comment> text";
wenzelm
parents: 61503
diff changeset
   230
  are admitted as well. A marginal @{syntax comment} is of the form
634cd44bb1d3 symbolic syntax "\<comment> text";
wenzelm
parents: 61503
diff changeset
   231
  \<^verbatim>\<open>--\<close>~@{syntax text} or \<^verbatim>\<open>\<comment>\<close>~@{syntax text}. Any number of these may occur
634cd44bb1d3 symbolic syntax "\<comment> text";
wenzelm
parents: 61503
diff changeset
   232
  within Isabelle/Isar commands.
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   233
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   234
  @{rail \<open>
56499
7e0178c84994 allow text cartouches in regular outer syntax categories "text" and "altstring";
wenzelm
parents: 56451
diff changeset
   235
    @{syntax_def text}: @{syntax verbatim} | @{syntax cartouche} | @{syntax nameref}
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   236
    ;
61579
634cd44bb1d3 symbolic syntax "\<comment> text";
wenzelm
parents: 61503
diff changeset
   237
    @{syntax_def comment}: ('--' | @'\<comment>') @{syntax text}
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   238
  \<close>}
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   239
\<close>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   240
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   241
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   242
subsection \<open>Type classes, sorts and arities\<close>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   243
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   244
text \<open>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   245
  Classes are specified by plain names.  Sorts have a very simple
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   246
  inner syntax, which is either a single class name \<open>c\<close> or a
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   247
  list \<open>{c\<^sub>1, \<dots>, c\<^sub>n}\<close> referring to the
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   248
  intersection of these classes.  The syntax of type arities is given
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   249
  directly at the outer level.
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   250
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   251
  @{rail \<open>
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   252
    @{syntax_def classdecl}: @{syntax name} (('<' | '\<subseteq>') (@{syntax nameref} + ','))?
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   253
    ;
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   254
    @{syntax_def sort}: @{syntax nameref}
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   255
    ;
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   256
    @{syntax_def arity}: ('(' (@{syntax sort} + ',') ')')? @{syntax sort}
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   257
  \<close>}
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   258
\<close>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   259
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   260
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   261
subsection \<open>Types and terms \label{sec:types-terms}\<close>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   262
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   263
text \<open>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   264
  The actual inner Isabelle syntax, that of types and terms of the
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   265
  logic, is far too sophisticated in order to be modelled explicitly
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   266
  at the outer theory level.  Basically, any such entity has to be
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   267
  quoted to turn it into a single token (the parsing and type-checking
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   268
  is performed internally later).  For convenience, a slightly more
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   269
  liberal convention is adopted: quotes may be omitted for any type or
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   270
  term that is already atomic at the outer level.  For example, one
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   271
  may just write \<^verbatim>\<open>x\<close> instead of quoted \<^verbatim>\<open>"x"\<close>.
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   272
  Note that symbolic identifiers (e.g.\ \<^verbatim>\<open>++\<close> or \<open>\<forall>\<close> are available as well,
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   273
  provided these have not been superseded
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   274
  by commands or other keywords already (such as \<^verbatim>\<open>=\<close> or
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   275
  \<^verbatim>\<open>+\<close>).
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   276
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   277
  @{rail \<open>
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   278
    @{syntax_def type}: @{syntax nameref} | @{syntax typefree} |
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   279
      @{syntax typevar}
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   280
    ;
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   281
    @{syntax_def term}: @{syntax nameref} | @{syntax var}
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   282
    ;
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   283
    @{syntax_def prop}: @{syntax term}
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   284
  \<close>}
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   285
59853
4039d8aecda4 more uniform syntax for named instantiations;
wenzelm
parents: 59785
diff changeset
   286
  Positional instantiations are specified as a sequence of terms, or the
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   287
  placeholder ``\<open>_\<close>'' (underscore), which means to skip a position.
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   288
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   289
  @{rail \<open>
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   290
    @{syntax_def inst}: '_' | @{syntax term}
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   291
    ;
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   292
    @{syntax_def insts}: (@{syntax inst} *)
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   293
  \<close>}
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   294
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   295
  Named instantiations are specified as pairs of assignments \<open>v =
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   296
  t\<close>, which refer to schematic variables in some theorem that is
59853
4039d8aecda4 more uniform syntax for named instantiations;
wenzelm
parents: 59785
diff changeset
   297
  instantiated. Both type and terms instantiations are admitted, and
4039d8aecda4 more uniform syntax for named instantiations;
wenzelm
parents: 59785
diff changeset
   298
  distinguished by the usual syntax of variable names.
4039d8aecda4 more uniform syntax for named instantiations;
wenzelm
parents: 59785
diff changeset
   299
4039d8aecda4 more uniform syntax for named instantiations;
wenzelm
parents: 59785
diff changeset
   300
  @{rail \<open>
4039d8aecda4 more uniform syntax for named instantiations;
wenzelm
parents: 59785
diff changeset
   301
    @{syntax_def named_inst}: variable '=' (type | term)
4039d8aecda4 more uniform syntax for named instantiations;
wenzelm
parents: 59785
diff changeset
   302
    ;
4039d8aecda4 more uniform syntax for named instantiations;
wenzelm
parents: 59785
diff changeset
   303
    @{syntax_def named_insts}: (named_inst @'and' +)
4039d8aecda4 more uniform syntax for named instantiations;
wenzelm
parents: 59785
diff changeset
   304
    ;
4039d8aecda4 more uniform syntax for named instantiations;
wenzelm
parents: 59785
diff changeset
   305
    variable: @{syntax name} | @{syntax var} | @{syntax typefree} | @{syntax typevar}
4039d8aecda4 more uniform syntax for named instantiations;
wenzelm
parents: 59785
diff changeset
   306
  \<close>}
4039d8aecda4 more uniform syntax for named instantiations;
wenzelm
parents: 59785
diff changeset
   307
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   308
  Type declarations and definitions usually refer to @{syntax
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   309
  typespec} on the left-hand side.  This models basic type constructor
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   310
  application at the outer syntax level.  Note that only plain postfix
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   311
  notation is available here, but no infixes.
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   312
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   313
  @{rail \<open>
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   314
    @{syntax_def typespec}:
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   315
      (() | @{syntax typefree} | '(' ( @{syntax typefree} + ',' ) ')') @{syntax name}
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   316
    ;
42705
528a2ba8fa74 tuned some syntax names;
wenzelm
parents: 42651
diff changeset
   317
    @{syntax_def typespec_sorts}:
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   318
      (() | (@{syntax typefree} ('::' @{syntax sort})?) |
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   319
        '(' ( (@{syntax typefree} ('::' @{syntax sort})?) + ',' ) ')') @{syntax name}
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   320
  \<close>}
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   321
\<close>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   322
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   323
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   324
subsection \<open>Term patterns and declarations \label{sec:term-decls}\<close>
28754
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   325
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   326
text \<open>Wherever explicit propositions (or term fragments) occur in a
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   327
  proof text, casual binding of schematic term variables may be given
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   328
  specified via patterns of the form ``\<open>(\<IS> p\<^sub>1 \<dots> p\<^sub>n)\<close>''.
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   329
  This works both for @{syntax term} and @{syntax prop}.
28754
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   330
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   331
  @{rail \<open>
42705
528a2ba8fa74 tuned some syntax names;
wenzelm
parents: 42651
diff changeset
   332
    @{syntax_def term_pat}: '(' (@'is' @{syntax term} +) ')'
28754
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   333
    ;
42705
528a2ba8fa74 tuned some syntax names;
wenzelm
parents: 42651
diff changeset
   334
    @{syntax_def prop_pat}: '(' (@'is' @{syntax prop} +) ')'
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   335
  \<close>}
28754
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   336
61421
e0825405d398 more symbols;
wenzelm
parents: 61252
diff changeset
   337
  \<^medskip>
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   338
  Declarations of local variables \<open>x :: \<tau>\<close> and
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   339
  logical propositions \<open>a : \<phi>\<close> represent different views on
28754
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   340
  the same principle of introducing a local scope.  In practice, one
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   341
  may usually omit the typing of @{syntax vars} (due to
28754
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   342
  type-inference), and the naming of propositions (due to implicit
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   343
  references of current facts).  In any case, Isar proof elements
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   344
  usually admit to introduce multiple such items simultaneously.
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   345
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   346
  @{rail \<open>
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   347
    @{syntax_def vars}: (@{syntax name} +) ('::' @{syntax type})?
28754
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   348
    ;
42705
528a2ba8fa74 tuned some syntax names;
wenzelm
parents: 42651
diff changeset
   349
    @{syntax_def props}: @{syntax thmdecl}? (@{syntax prop} @{syntax prop_pat}? +)
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   350
  \<close>}
28754
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   351
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   352
  The treatment of multiple declarations corresponds to the
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   353
  complementary focus of @{syntax vars} versus @{syntax props}.  In
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   354
  ``\<open>x\<^sub>1 \<dots> x\<^sub>n :: \<tau>\<close>'' the typing refers to all variables, while
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   355
  in \<open>a: \<phi>\<^sub>1 \<dots> \<phi>\<^sub>n\<close> the naming refers to all propositions
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   356
  collectively.  Isar language elements that refer to @{syntax vars}
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   357
  or @{syntax props} typically admit separate typings or namings via
28754
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   358
  another level of iteration, with explicit @{keyword_ref "and"}
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   359
  separators; e.g.\ see @{command "fix"} and @{command "assume"} in
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   360
  \secref{sec:proof-context}.
59785
4e6ab5831cc0 clarified syntax category "fixes";
wenzelm
parents: 58861
diff changeset
   361
4e6ab5831cc0 clarified syntax category "fixes";
wenzelm
parents: 58861
diff changeset
   362
  @{rail \<open>
4e6ab5831cc0 clarified syntax category "fixes";
wenzelm
parents: 58861
diff changeset
   363
    @{syntax_def "fixes"}:
4e6ab5831cc0 clarified syntax category "fixes";
wenzelm
parents: 58861
diff changeset
   364
      ((@{syntax name} ('::' @{syntax type})? @{syntax mixfix}? | @{syntax vars}) + @'and')
4e6ab5831cc0 clarified syntax category "fixes";
wenzelm
parents: 58861
diff changeset
   365
    ;
4e6ab5831cc0 clarified syntax category "fixes";
wenzelm
parents: 58861
diff changeset
   366
    @{syntax_def "for_fixes"}: (@'for' @{syntax "fixes"})?
4e6ab5831cc0 clarified syntax category "fixes";
wenzelm
parents: 58861
diff changeset
   367
  \<close>}
4e6ab5831cc0 clarified syntax category "fixes";
wenzelm
parents: 58861
diff changeset
   368
4e6ab5831cc0 clarified syntax category "fixes";
wenzelm
parents: 58861
diff changeset
   369
  The category @{syntax "fixes"} is a richer variant of @{syntax vars}: it
4e6ab5831cc0 clarified syntax category "fixes";
wenzelm
parents: 58861
diff changeset
   370
  admits specification of mixfix syntax for the entities that are introduced
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   371
  into the context. An optional suffix ``@{keyword "for"}~\<open>fixes\<close>''
59785
4e6ab5831cc0 clarified syntax category "fixes";
wenzelm
parents: 58861
diff changeset
   372
  is admitted in many situations to indicate a so-called ``eigen-context''
4e6ab5831cc0 clarified syntax category "fixes";
wenzelm
parents: 58861
diff changeset
   373
  of a formal element: the result will be exported and thus generalized over
4e6ab5831cc0 clarified syntax category "fixes";
wenzelm
parents: 58861
diff changeset
   374
  the given variables.\<close>
28754
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   375
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   376
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   377
subsection \<open>Attributes and theorems \label{sec:syn-att}\<close>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   378
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   379
text \<open>Attributes have their own ``semi-inner'' syntax, in the sense
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   380
  that input conforming to @{syntax args} below is parsed by the
28754
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   381
  attribute a second time.  The attribute argument specifications may
6f2e67a3dfaa moved section "Proof method expressions" to proof chapter;
wenzelm
parents: 28753
diff changeset
   382
  be any sequence of atomic entities (identifiers, strings etc.), or
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   383
  properly bracketed argument lists.  Below @{syntax atom} refers to
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   384
  any atomic entity, including any @{syntax keyword} conforming to
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   385
  @{syntax symident}.
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   386
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   387
  @{rail \<open>
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   388
    @{syntax_def atom}: @{syntax nameref} | @{syntax typefree} |
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   389
      @{syntax typevar} | @{syntax var} | @{syntax nat} | @{syntax float} |
55045
99056d23e05b cartouche within nested args (attributes, methods, etc.);
wenzelm
parents: 55033
diff changeset
   390
      @{syntax keyword} | @{syntax cartouche}
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   391
    ;
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   392
    arg: @{syntax atom} | '(' @{syntax args} ')' | '[' @{syntax args} ']'
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   393
    ;
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   394
    @{syntax_def args}: arg *
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   395
    ;
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   396
    @{syntax_def attributes}: '[' (@{syntax nameref} @{syntax args} * ',') ']'
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   397
  \<close>}
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   398
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   399
  Theorem specifications come in several flavors: @{syntax axmdecl}
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   400
  and @{syntax thmdecl} usually refer to axioms, assumptions or
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   401
  results of goal statements, while @{syntax thmdef} collects lists of
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   402
  existing theorems.  Existing theorems are given by @{syntax thmref}
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   403
  and @{syntax thmrefs}, the former requires an actual singleton
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   404
  result.
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   405
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   406
  There are three forms of theorem references:
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   407
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   408
  \<^enum> named facts \<open>a\<close>,
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   409
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   410
  \<^enum> selections from named facts \<open>a(i)\<close> or \<open>a(j - k)\<close>,
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   411
61421
e0825405d398 more symbols;
wenzelm
parents: 61252
diff changeset
   412
  \<^enum> literal fact propositions using token syntax @{syntax_ref altstring}
61503
28e788ca2c5d more control symbols;
wenzelm
parents: 61494
diff changeset
   413
  \<^verbatim>\<open>`\<close>\<open>\<phi>\<close>\<^verbatim>\<open>`\<close> or @{syntax_ref cartouche}
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   414
  \<open>\<open>\<phi>\<close>\<close> (see also method @{method_ref fact}).
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   415
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   416
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   417
  Any kind of theorem specification may include lists of attributes
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   418
  both on the left and right hand sides; attributes are applied to any
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   419
  immediately preceding fact.  If names are omitted, the theorems are
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   420
  not stored within the theorem database of the theory or proof
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   421
  context, but any given attributes are applied nonetheless.
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   422
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   423
  An extra pair of brackets around attributes (like ``\<open>[[simproc a]]\<close>'') abbreviates a theorem reference involving an
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   424
  internal dummy fact, which will be ignored later on.  So only the
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   425
  effect of the attribute on the background context will persist.
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   426
  This form of in-place declarations is particularly useful with
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   427
  commands like @{command "declare"} and @{command "using"}.
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   428
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   429
  @{rail \<open>
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   430
    @{syntax_def axmdecl}: @{syntax name} @{syntax attributes}? ':'
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   431
    ;
60631
441fdbfbb2d3 documentation for 'subgoal' command;
wenzelm
parents: 60270
diff changeset
   432
    @{syntax_def thmbind}:
441fdbfbb2d3 documentation for 'subgoal' command;
wenzelm
parents: 60270
diff changeset
   433
      @{syntax name} @{syntax attributes} | @{syntax name} | @{syntax attributes}
441fdbfbb2d3 documentation for 'subgoal' command;
wenzelm
parents: 60270
diff changeset
   434
    ;
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   435
    @{syntax_def thmdecl}: thmbind ':'
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   436
    ;
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   437
    @{syntax_def thmdef}: thmbind '='
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   438
    ;
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   439
    @{syntax_def thmref}:
56499
7e0178c84994 allow text cartouches in regular outer syntax categories "text" and "altstring";
wenzelm
parents: 56451
diff changeset
   440
      (@{syntax nameref} selection? | @{syntax altstring} | @{syntax cartouche})
7e0178c84994 allow text cartouches in regular outer syntax categories "text" and "altstring";
wenzelm
parents: 56451
diff changeset
   441
        @{syntax attributes}? |
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   442
      '[' @{syntax attributes} ']'
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   443
    ;
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   444
    @{syntax_def thmrefs}: @{syntax thmref} +
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   445
    ;
42596
6c621a9d612a modernized rail diagrams using @{rail} antiquotation;
wenzelm
parents: 40296
diff changeset
   446
    selection: '(' ((@{syntax nat} | @{syntax nat} '-' @{syntax nat}?) + ',') ')'
55112
b1a5d603fd12 prefer rail cartouche -- avoid back-slashed quotes;
wenzelm
parents: 55045
diff changeset
   447
  \<close>}
58618
782f0b662cae more cartouches;
wenzelm
parents: 58552
diff changeset
   448
\<close>
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   449
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   450
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   451
section \<open>Diagnostic commands\<close>
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   452
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   453
text \<open>
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   454
  \begin{matharray}{rcl}
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   455
    @{command_def "print_theory"}\<open>\<^sup>*\<close> & : & \<open>context \<rightarrow>\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   456
    @{command_def "print_definitions"}\<open>\<^sup>*\<close> & : & \<open>context \<rightarrow>\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   457
    @{command_def "print_methods"}\<open>\<^sup>*\<close> & : & \<open>context \<rightarrow>\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   458
    @{command_def "print_attributes"}\<open>\<^sup>*\<close> & : & \<open>context \<rightarrow>\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   459
    @{command_def "print_theorems"}\<open>\<^sup>*\<close> & : & \<open>context \<rightarrow>\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   460
    @{command_def "find_theorems"}\<open>\<^sup>*\<close> & : & \<open>context \<rightarrow>\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   461
    @{command_def "find_consts"}\<open>\<^sup>*\<close> & : & \<open>context \<rightarrow>\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   462
    @{command_def "thm_deps"}\<open>\<^sup>*\<close> & : & \<open>context \<rightarrow>\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   463
    @{command_def "unused_thms"}\<open>\<^sup>*\<close> & : & \<open>context \<rightarrow>\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   464
    @{command_def "print_facts"}\<open>\<^sup>*\<close> & : & \<open>context \<rightarrow>\<close> \\
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   465
    @{command_def "print_term_bindings"}\<open>\<^sup>*\<close> & : & \<open>context \<rightarrow>\<close> \\
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   466
  \end{matharray}
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   467
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   468
  @{rail \<open>
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   469
    (@@{command print_theory} |
61252
c165f0472d57 separate command 'print_definitions';
wenzelm
parents: 60674
diff changeset
   470
      @@{command print_definitions} |
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   471
      @@{command print_methods} |
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   472
      @@{command print_attributes} |
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   473
      @@{command print_theorems} |
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   474
      @@{command print_facts}) ('!'?)
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   475
    ;
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   476
    @@{command find_theorems} ('(' @{syntax nat}? 'with_dups'? ')')? \<newline> (thm_criterion*)
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   477
    ;
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   478
    thm_criterion: ('-'?) ('name' ':' @{syntax nameref} | 'intro' | 'elim' | 'dest' |
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   479
      'solves' | 'simp' ':' @{syntax term} | @{syntax term})
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   480
    ;
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   481
    @@{command find_consts} (const_criterion*)
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   482
    ;
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   483
    const_criterion: ('-'?)
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   484
      ('name' ':' @{syntax nameref} | 'strict' ':' @{syntax type} | @{syntax type})
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   485
    ;
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   486
    @@{command thm_deps} @{syntax thmrefs}
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   487
    ;
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   488
    @@{command unused_thms} ((@{syntax name} +) '-' (@{syntax name} * ))?
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   489
  \<close>}
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   490
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   491
  These commands print certain parts of the theory and proof context.
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   492
  Note that there are some further ones available, such as for the set
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   493
  of rules declared for simplifications.
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   494
61439
2bf52eec4e8a more symbols;
wenzelm
parents: 61421
diff changeset
   495
  \<^descr> @{command "print_theory"} prints the main logical content of the
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   496
  background theory; the ``\<open>!\<close>'' option indicates extra verbosity.
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   497
61439
2bf52eec4e8a more symbols;
wenzelm
parents: 61421
diff changeset
   498
  \<^descr> @{command "print_definitions"} prints dependencies of definitional
61252
c165f0472d57 separate command 'print_definitions';
wenzelm
parents: 60674
diff changeset
   499
  specifications within the background theory, which may be constants
c165f0472d57 separate command 'print_definitions';
wenzelm
parents: 60674
diff changeset
   500
  \secref{sec:consts} or types (\secref{sec:types-pure},
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   501
  \secref{sec:hol-typedef}); the ``\<open>!\<close>'' option indicates extra
61252
c165f0472d57 separate command 'print_definitions';
wenzelm
parents: 60674
diff changeset
   502
  verbosity.
c165f0472d57 separate command 'print_definitions';
wenzelm
parents: 60674
diff changeset
   503
61439
2bf52eec4e8a more symbols;
wenzelm
parents: 61421
diff changeset
   504
  \<^descr> @{command "print_methods"} prints all proof methods available in the
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   505
  current theory context; the ``\<open>!\<close>'' option indicates extra
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   506
  verbosity.
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   507
61439
2bf52eec4e8a more symbols;
wenzelm
parents: 61421
diff changeset
   508
  \<^descr> @{command "print_attributes"} prints all attributes available in the
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   509
  current theory context; the ``\<open>!\<close>'' option indicates extra
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   510
  verbosity.
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   511
61439
2bf52eec4e8a more symbols;
wenzelm
parents: 61421
diff changeset
   512
  \<^descr> @{command "print_theorems"} prints theorems of the background theory
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   513
  resulting from the last command; the ``\<open>!\<close>'' option indicates
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   514
  extra verbosity.
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   515
61439
2bf52eec4e8a more symbols;
wenzelm
parents: 61421
diff changeset
   516
  \<^descr> @{command "print_facts"} prints all local facts of the current
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   517
  context, both named and unnamed ones; the ``\<open>!\<close>'' option indicates
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   518
  extra verbosity.
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   519
61439
2bf52eec4e8a more symbols;
wenzelm
parents: 61421
diff changeset
   520
  \<^descr> @{command "print_term_bindings"} prints all term bindings that
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   521
  are present in the context.
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   522
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   523
  \<^descr> @{command "find_theorems"}~\<open>criteria\<close> retrieves facts
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   524
  from the theory or proof context matching all of given search
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   525
  criteria.  The criterion \<open>name: p\<close> selects all theorems
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   526
  whose fully qualified name matches pattern \<open>p\<close>, which may
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   527
  contain ``\<open>*\<close>'' wildcards.  The criteria \<open>intro\<close>,
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   528
  \<open>elim\<close>, and \<open>dest\<close> select theorems that match the
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   529
  current goal as introduction, elimination or destruction rules,
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   530
  respectively.  The criterion \<open>solves\<close> returns all rules
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   531
  that would directly solve the current goal.  The criterion
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   532
  \<open>simp: t\<close> selects all rewrite rules whose left-hand side
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   533
  matches the given term.  The criterion term \<open>t\<close> selects all
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   534
  theorems that contain the pattern \<open>t\<close> -- as usual, patterns
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   535
  may contain occurrences of the dummy ``\<open>_\<close>'', schematic
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   536
  variables, and type constraints.
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   537
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   538
  Criteria can be preceded by ``\<open>-\<close>'' to select theorems that
61477
e467ae7aa808 more control symbols;
wenzelm
parents: 61473
diff changeset
   539
  do \<^emph>\<open>not\<close> match. Note that giving the empty list of criteria
e467ae7aa808 more control symbols;
wenzelm
parents: 61473
diff changeset
   540
  yields \<^emph>\<open>all\<close> currently known facts.  An optional limit for the
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   541
  number of printed facts may be given; the default is 40.  By
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   542
  default, duplicates are removed from the search result. Use
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   543
  \<open>with_dups\<close> to display duplicates.
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   544
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   545
  \<^descr> @{command "find_consts"}~\<open>criteria\<close> prints all constants
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   546
  whose type meets all of the given criteria. The criterion \<open>strict: ty\<close> is met by any type that matches the type pattern
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   547
  \<open>ty\<close>.  Patterns may contain both the dummy type ``\<open>_\<close>''
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   548
  and sort constraints. The criterion \<open>ty\<close> is similar, but it
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   549
  also matches against subtypes. The criterion \<open>name: p\<close> and
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   550
  the prefix ``\<open>-\<close>'' function as described for @{command
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   551
  "find_theorems"}.
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   552
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   553
  \<^descr> @{command "thm_deps"}~\<open>a\<^sub>1 \<dots> a\<^sub>n\<close>
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   554
  visualizes dependencies of facts, using Isabelle's graph browser
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   555
  tool (see also @{cite "isabelle-system"}).
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   556
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   557
  \<^descr> @{command "unused_thms"}~\<open>A\<^sub>1 \<dots> A\<^sub>m - B\<^sub>1 \<dots> B\<^sub>n\<close>
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   558
  displays all theorems that are proved in theories \<open>B\<^sub>1 \<dots> B\<^sub>n\<close>
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   559
  or their parents but not in \<open>A\<^sub>1 \<dots> A\<^sub>m\<close> or their parents and
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   560
  that are never used.
61493
0debd22f0c0e isabelle update_cartouches -t;
wenzelm
parents: 61477
diff changeset
   561
  If \<open>n\<close> is \<open>0\<close>, the end of the range of theories
60674
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   562
  defaults to the current theory. If no range is specified,
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   563
  only the unused theorems in the current theory are displayed.
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   564
\<close>
2f66099fb472 clarified sections;
wenzelm
parents: 60631
diff changeset
   565
27037
33d95687514e renamed theory "syntax" to "Outer_Syntax";
wenzelm
parents:
diff changeset
   566
end