doc-src/IsarRef/Thy/pure.thy
author wenzelm
Mon, 02 Jun 2008 21:01:42 +0200
changeset 27035 d038a2ba87f6
parent 26957 e3f04fdd994d
child 27040 3d3e6e07b931
permissions -rw-r--r--
renamed theory "intro" to "Introduction";
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     1
(* $Id$ *)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     2
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     3
theory pure
26957
e3f04fdd994d eliminated theory CPure;
wenzelm
parents: 26894
diff changeset
     4
imports Pure
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     5
begin
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     6
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     7
chapter {* Basic language elements \label{ch:pure-syntax} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     8
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
     9
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    10
  Subsequently, we introduce the main part of Pure theory and proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    11
  commands, together with fundamental proof methods and attributes.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    12
  \Chref{ch:gen-tools} describes further Isar elements provided by
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    13
  generic tools and packages (such as the Simplifier) that are either
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    14
  part of Pure Isabelle or pre-installed in most object logics.
26852
a31203f58b20 misc tuning;
wenzelm
parents: 26787
diff changeset
    15
  Specific language elements introduced by the major object-logics are
a31203f58b20 misc tuning;
wenzelm
parents: 26787
diff changeset
    16
  described in \chref{ch:hol} (Isabelle/HOL), \chref{ch:holcf}
a31203f58b20 misc tuning;
wenzelm
parents: 26787
diff changeset
    17
  (Isabelle/HOLCF), and \chref{ch:zf} (Isabelle/ZF).  Nevertheless,
a31203f58b20 misc tuning;
wenzelm
parents: 26787
diff changeset
    18
  examples given in the generic parts will usually refer to
a31203f58b20 misc tuning;
wenzelm
parents: 26787
diff changeset
    19
  Isabelle/HOL as well.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    20
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    21
  \medskip Isar commands may be either \emph{proper} document
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    22
  constructors, or \emph{improper commands}.  Some proof methods and
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    23
  attributes introduced later are classified as improper as well.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    24
  Improper Isar language elements, which are subsequently marked by
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    25
  ``@{text "\<^sup>*"}'', are often helpful when developing proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    26
  documents, while their use is discouraged for the final
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    27
  human-readable outcome.  Typical examples are diagnostic commands
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    28
  that print terms or theorems according to the current context; other
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    29
  commands emulate old-style tactical theorem proving.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    30
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    31
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    32
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    33
section {* Theory commands *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    34
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    35
subsection {* Markup commands \label{sec:markup-thy} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    36
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    37
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    38
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    39
    @{command_def "chapter"} & : & \isarkeep{local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    40
    @{command_def "section"} & : & \isarkeep{local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    41
    @{command_def "subsection"} & : & \isarkeep{local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    42
    @{command_def "subsubsection"} & : & \isarkeep{local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    43
    @{command_def "text"} & : & \isarkeep{local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    44
    @{command_def "text_raw"} & : & \isarkeep{local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    45
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    46
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    47
  Apart from formal comments (see \secref{sec:comments}), markup
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    48
  commands provide a structured way to insert text into the document
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    49
  generated from a theory (see \cite{isabelle-sys} for more
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    50
  information on Isabelle's document preparation tools).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    51
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    52
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    53
    ('chapter' | 'section' | 'subsection' | 'subsubsection' | 'text') target? text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    54
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    55
    'text\_raw' text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    56
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    57
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    58
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    59
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    60
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    61
  \item [@{command "chapter"}, @{command "section"}, @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    62
  "subsection"}, and @{command "subsubsection"}] mark chapter and
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    63
  section headings.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    64
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    65
  \item [@{command "text"}] specifies paragraphs of plain text.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    66
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    67
  \item [@{command "text_raw"}] inserts {\LaTeX} source into the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    68
  output, without additional markup.  Thus the full range of document
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    69
  manipulations becomes available.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    70
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    71
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    72
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    73
  The @{text "text"} argument of these markup commands (except for
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    74
  @{command "text_raw"}) may contain references to formal entities
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    75
  (``antiquotations'', see also \secref{sec:antiq}).  These are
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    76
  interpreted in the present theory context, or the named @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    77
  "target"}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    78
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    79
  Any of these markup elements corresponds to a {\LaTeX} command with
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    80
  the name prefixed by @{verbatim "\\isamarkup"}.  For the sectioning
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    81
  commands this is a plain macro with a single argument, e.g.\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    82
  @{verbatim "\\isamarkupchapter{"}@{text "\<dots>"}@{verbatim "}"} for
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    83
  @{command "chapter"}.  The @{command "text"} markup results in a
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
    84
  {\LaTeX} environment @{verbatim "\\begin{isamarkuptext}"} @{text
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
    85
  "\<dots>"} @{verbatim "\\end{isamarkuptext}"}, while @{command "text_raw"}
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    86
  causes the text to be inserted directly into the {\LaTeX} source.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    87
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    88
  \medskip Additional markup commands are available for proofs (see
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    89
  \secref{sec:markup-prf}).  Also note that the @{command_ref
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    90
  "header"} declaration (see \secref{sec:begin-thy}) admits to insert
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    91
  section markup just preceding the actual theory definition.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    92
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    93
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    94
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    95
subsection {* Type classes and sorts \label{sec:classes} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    96
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    97
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    98
  \begin{matharray}{rcll}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
    99
    @{command_def "classes"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   100
    @{command_def "classrel"} & : & \isartrans{theory}{theory} & (axiomatic!) \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   101
    @{command_def "defaultsort"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   102
    @{command_def "class_deps"} & : & \isarkeep{theory~|~proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   103
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   104
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   105
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   106
    'classes' (classdecl +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   107
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   108
    'classrel' (nameref ('<' | subseteq) nameref + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   109
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   110
    'defaultsort' sort
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   111
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   112
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   113
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   114
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   115
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   116
  \item [@{command "classes"}~@{text "c \<subseteq> c\<^sub>1, \<dots>, c\<^sub>n"}]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   117
  declares class @{text c} to be a subclass of existing classes @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   118
  "c\<^sub>1, \<dots>, c\<^sub>n"}.  Cyclic class structures are not permitted.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   119
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   120
  \item [@{command "classrel"}~@{text "c\<^sub>1 \<subseteq> c\<^sub>2"}] states
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   121
  subclass relations between existing classes @{text "c\<^sub>1"} and
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   122
  @{text "c\<^sub>2"}.  This is done axiomatically!  The @{command_ref
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   123
  "instance"} command (see \secref{sec:axclass}) provides a way to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   124
  introduce proven class relations.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   125
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   126
  \item [@{command "defaultsort"}~@{text s}] makes sort @{text s} the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   127
  new default sort for any type variables given without sort
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   128
  constraints.  Usually, the default sort would be only changed when
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   129
  defining a new object-logic.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   130
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   131
  \item [@{command "class_deps"}] visualizes the subclass relation,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   132
  using Isabelle's graph browser tool (see also \cite{isabelle-sys}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   133
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   134
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   135
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   136
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   137
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   138
subsection {* Primitive types and type abbreviations \label{sec:types-pure} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   139
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   140
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   141
  \begin{matharray}{rcll}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   142
    @{command_def "types"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   143
    @{command_def "typedecl"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   144
    @{command_def "nonterminals"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   145
    @{command_def "arities"} & : & \isartrans{theory}{theory} & (axiomatic!) \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   146
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   147
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   148
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   149
    'types' (typespec '=' type infix? +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   150
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   151
    'typedecl' typespec infix?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   152
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   153
    'nonterminals' (name +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   154
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   155
    'arities' (nameref '::' arity +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   156
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   157
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   158
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   159
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   160
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   161
  \item [@{command "types"}~@{text "(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>n) t = \<tau>"}]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   162
  introduces \emph{type synonym} @{text "(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>n) t"}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   163
  for existing type @{text "\<tau>"}.  Unlike actual type definitions, as
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   164
  are available in Isabelle/HOL for example, type synonyms are just
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   165
  purely syntactic abbreviations without any logical significance.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   166
  Internally, type synonyms are fully expanded.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   167
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   168
  \item [@{command "typedecl"}~@{text "(\<alpha>\<^sub>1, \<dots>, \<alpha>\<^sub>n) t"}]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   169
  declares a new type constructor @{text t}, intended as an actual
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   170
  logical type (of the object-logic, if available).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   171
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   172
  \item [@{command "nonterminals"}~@{text c}] declares type
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   173
  constructors @{text c} (without arguments) to act as purely
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   174
  syntactic types, i.e.\ nonterminal symbols of Isabelle's inner
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   175
  syntax of terms or types.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   176
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   177
  \item [@{command "arities"}~@{text "t :: (s\<^sub>1, \<dots>, s\<^sub>n)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   178
  s"}] augments Isabelle's order-sorted signature of types by new type
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   179
  constructor arities.  This is done axiomatically!  The @{command_ref
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   180
  "instance"} command (see \S\ref{sec:axclass}) provides a way to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   181
  introduce proven type arities.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   182
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   183
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   184
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   185
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   186
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   187
subsection {* Primitive constants and definitions \label{sec:consts} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   188
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   189
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   190
  Definitions essentially express abbreviations within the logic.  The
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   191
  simplest form of a definition is @{text "c :: \<sigma> \<equiv> t"}, where @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   192
  c} is a newly declared constant.  Isabelle also allows derived forms
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   193
  where the arguments of @{text c} appear on the left, abbreviating a
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   194
  prefix of @{text \<lambda>}-abstractions, e.g.\ @{text "c \<equiv> \<lambda>x y. t"} may be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   195
  written more conveniently as @{text "c x y \<equiv> t"}.  Moreover,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   196
  definitions may be weakened by adding arbitrary pre-conditions:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   197
  @{text "A \<Longrightarrow> c x y \<equiv> t"}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   198
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   199
  \medskip The built-in well-formedness conditions for definitional
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   200
  specifications are:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   201
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   202
  \begin{itemize}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   203
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   204
  \item Arguments (on the left-hand side) must be distinct variables.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   205
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   206
  \item All variables on the right-hand side must also appear on the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   207
  left-hand side.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   208
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   209
  \item All type variables on the right-hand side must also appear on
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   210
  the left-hand side; this prohibits @{text "0 :: nat \<equiv> length ([] ::
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   211
  \<alpha> list)"} for example.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   212
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   213
  \item The definition must not be recursive.  Most object-logics
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   214
  provide definitional principles that can be used to express
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   215
  recursion safely.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   216
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   217
  \end{itemize}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   218
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   219
  Overloading means that a constant being declared as @{text "c :: \<alpha>
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   220
  decl"} may be defined separately on type instances @{text "c ::
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   221
  (\<beta>\<^sub>1, \<dots>, \<beta>\<^sub>n) t decl"} for each type constructor @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   222
  t}.  The right-hand side may mention overloaded constants
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   223
  recursively at type instances corresponding to the immediate
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   224
  argument types @{text "\<beta>\<^sub>1, \<dots>, \<beta>\<^sub>n"}.  Incomplete
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   225
  specification patterns impose global constraints on all occurrences,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   226
  e.g.\ @{text "d :: \<alpha> \<times> \<alpha>"} on the left-hand side means that all
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   227
  corresponding occurrences on some right-hand side need to be an
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   228
  instance of this, general @{text "d :: \<alpha> \<times> \<beta>"} will be disallowed.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   229
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   230
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   231
    @{command_def "consts"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   232
    @{command_def "defs"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   233
    @{command_def "constdefs"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   234
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   235
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   236
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   237
    'consts' ((name '::' type mixfix?) +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   238
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   239
    'defs' ('(' 'unchecked'? 'overloaded'? ')')? \\ (axmdecl prop +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   240
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   241
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   242
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   243
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   244
    'constdefs' structs? (constdecl? constdef +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   245
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   246
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   247
    structs: '(' 'structure' (vars + 'and') ')'
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   248
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   249
    constdecl:  ((name '::' type mixfix | name '::' type | name mixfix) 'where'?) | name 'where'
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   250
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   251
    constdef: thmdecl? prop
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   252
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   253
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   254
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   255
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   256
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   257
  \item [@{command "consts"}~@{text "c :: \<sigma>"}] declares constant
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   258
  @{text c} to have any instance of type scheme @{text \<sigma>}.  The
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   259
  optional mixfix annotations may attach concrete syntax to the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   260
  constants declared.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   261
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   262
  \item [@{command "defs"}~@{text "name: eqn"}] introduces @{text eqn}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   263
  as a definitional axiom for some existing constant.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   264
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   265
  The @{text "(unchecked)"} option disables global dependency checks
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   266
  for this definition, which is occasionally useful for exotic
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   267
  overloading.  It is at the discretion of the user to avoid malformed
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   268
  theory specifications!
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   269
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   270
  The @{text "(overloaded)"} option declares definitions to be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   271
  potentially overloaded.  Unless this option is given, a warning
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   272
  message would be issued for any definitional equation with a more
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   273
  special type than that of the corresponding constant declaration.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   274
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   275
  \item [@{command "constdefs"}] provides a streamlined combination of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   276
  constants declarations and definitions: type-inference takes care of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   277
  the most general typing of the given specification (the optional
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   278
  type constraint may refer to type-inference dummies ``@{text
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   279
  _}'' as usual).  The resulting type declaration needs to agree with
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   280
  that of the specification; overloading is \emph{not} supported here!
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   281
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   282
  The constant name may be omitted altogether, if neither type nor
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   283
  syntax declarations are given.  The canonical name of the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   284
  definitional axiom for constant @{text c} will be @{text c_def},
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   285
  unless specified otherwise.  Also note that the given list of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   286
  specifications is processed in a strictly sequential manner, with
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   287
  type-checking being performed independently.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   288
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   289
  An optional initial context of @{text "(structure)"} declarations
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   290
  admits use of indexed syntax, using the special symbol @{verbatim
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   291
  "\<index>"} (printed as ``@{text "\<index>"}'').  The latter concept is
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   292
  particularly useful with locales (see also \S\ref{sec:locale}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   293
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   294
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   295
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   296
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   297
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   298
subsection {* Syntax and translations \label{sec:syn-trans} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   299
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   300
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   301
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   302
    @{command_def "syntax"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   303
    @{command_def "no_syntax"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   304
    @{command_def "translations"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   305
    @{command_def "no_translations"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   306
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   307
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   308
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   309
    ('syntax' | 'no\_syntax') mode? (constdecl +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   310
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   311
    ('translations' | 'no\_translations') (transpat ('==' | '=>' | '<=' | rightleftharpoons | rightharpoonup | leftharpoondown) transpat +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   312
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   313
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   314
    mode: ('(' ( name | 'output' | name 'output' ) ')')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   315
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   316
    transpat: ('(' nameref ')')? string
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   317
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   318
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   319
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   320
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   321
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   322
  \item [@{command "syntax"}~@{text "(mode) decls"}] is similar to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   323
  @{command "consts"}~@{text decls}, except that the actual logical
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   324
  signature extension is omitted.  Thus the context free grammar of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   325
  Isabelle's inner syntax may be augmented in arbitrary ways,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   326
  independently of the logic.  The @{text mode} argument refers to the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   327
  print mode that the grammar rules belong; unless the @{keyword_ref
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   328
  "output"} indicator is given, all productions are added both to the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   329
  input and output grammar.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   330
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   331
  \item [@{command "no_syntax"}~@{text "(mode) decls"}] removes
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   332
  grammar declarations (and translations) resulting from @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   333
  decls}, which are interpreted in the same manner as for @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   334
  "syntax"} above.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   335
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   336
  \item [@{command "translations"}~@{text rules}] specifies syntactic
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   337
  translation rules (i.e.\ macros): parse~/ print rules (@{text "\<rightleftharpoons>"}),
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   338
  parse rules (@{text "\<rightharpoonup>"}), or print rules (@{text "\<leftharpoondown>"}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   339
  Translation patterns may be prefixed by the syntactic category to be
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   340
  used for parsing; the default is @{text logic}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   341
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   342
  \item [@{command "no_translations"}~@{text rules}] removes syntactic
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   343
  translation rules, which are interpreted in the same manner as for
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   344
  @{command "translations"} above.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   345
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   346
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   347
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   348
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   349
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   350
subsection {* Axioms and theorems \label{sec:axms-thms} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   351
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   352
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   353
  \begin{matharray}{rcll}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   354
    @{command_def "axioms"} & : & \isartrans{theory}{theory} & (axiomatic!) \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   355
    @{command_def "lemmas"} & : & \isarkeep{local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   356
    @{command_def "theorems"} & : & isarkeep{local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   357
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   358
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   359
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   360
    'axioms' (axmdecl prop +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   361
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   362
    ('lemmas' | 'theorems') target? (thmdef? thmrefs + 'and')
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   363
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   364
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   365
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   366
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   367
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   368
  \item [@{command "axioms"}~@{text "a: \<phi>"}] introduces arbitrary
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   369
  statements as axioms of the meta-logic.  In fact, axioms are
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   370
  ``axiomatic theorems'', and may be referred later just as any other
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   371
  theorem.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   372
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   373
  Axioms are usually only introduced when declaring new logical
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   374
  systems.  Everyday work is typically done the hard way, with proper
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   375
  definitions and proven theorems.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   376
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   377
  \item [@{command "lemmas"}~@{text "a = b\<^sub>1 \<dots> b\<^sub>n"}]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   378
  retrieves and stores existing facts in the theory context, or the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   379
  specified target context (see also \secref{sec:target}).  Typical
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   380
  applications would also involve attributes, to declare Simplifier
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   381
  rules, for example.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   382
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   383
  \item [@{command "theorems"}] is essentially the same as @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   384
  "lemmas"}, but marks the result as a different kind of facts.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   385
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   386
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   387
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   388
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   389
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   390
subsection {* Name spaces *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   391
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   392
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   393
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   394
    @{command_def "global"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   395
    @{command_def "local"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   396
    @{command_def "hide"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   397
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   398
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   399
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   400
    'hide' ('(open)')? name (nameref + )
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   401
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   402
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   403
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   404
  Isabelle organizes any kind of name declarations (of types,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   405
  constants, theorems etc.) by separate hierarchically structured name
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   406
  spaces.  Normally the user does not have to control the behavior of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   407
  name spaces by hand, yet the following commands provide some way to
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   408
  do so.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   409
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   410
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   411
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   412
  \item [@{command "global"} and @{command "local"}] change the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   413
  current name declaration mode.  Initially, theories start in
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   414
  @{command "local"} mode, causing all names to be automatically
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   415
  qualified by the theory name.  Changing this to @{command "global"}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   416
  causes all names to be declared without the theory prefix, until
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   417
  @{command "local"} is declared again.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   418
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   419
  Note that global names are prone to get hidden accidently later,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   420
  when qualified names of the same base name are introduced.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   421
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   422
  \item [@{command "hide"}~@{text "space names"}] fully removes
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   423
  declarations from a given name space (which may be @{text "class"},
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   424
  @{text "type"}, @{text "const"}, or @{text "fact"}); with the @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   425
  "(open)"} option, only the base name is hidden.  Global
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   426
  (unqualified) names may never be hidden.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   427
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   428
  Note that hiding name space accesses has no impact on logical
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   429
  declarations -- they remain valid internally.  Entities that are no
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   430
  longer accessible to the user are printed with the special qualifier
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   431
  ``@{text "??"}'' prefixed to the full internal name.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   432
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   433
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   434
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   435
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   436
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   437
subsection {* Incorporating ML code \label{sec:ML} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   438
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   439
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   440
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   441
    @{command_def "use"} & : & \isarkeep{theory~|~local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   442
    @{command_def "ML"} & : & \isarkeep{theory~|~local{\dsh}theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   443
    @{command_def "ML_val"} & : & \isartrans{\cdot}{\cdot} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   444
    @{command_def "ML_command"} & : & \isartrans{\cdot}{\cdot} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   445
    @{command_def "setup"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   446
    @{command_def "method_setup"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   447
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   448
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   449
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   450
    'use' name
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   451
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   452
    ('ML' | 'ML\_val' | 'ML\_command' | 'setup') text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   453
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   454
    'method\_setup' name '=' text text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   455
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   456
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   457
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   458
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   459
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   460
  \item [@{command "use"}~@{text "file"}] reads and executes ML
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   461
  commands from @{text "file"}.  The current theory context is passed
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   462
  down to the ML toplevel and may be modified, using @{ML
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   463
  "Context.>>"} or derived ML commands.  The file name is checked with
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   464
  the @{keyword_ref "uses"} dependency declaration given in the theory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   465
  header (see also \secref{sec:begin-thy}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   466
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   467
  \item [@{command "ML"}~@{text "text"}] is similar to @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   468
  "use"}, but executes ML commands directly from the given @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   469
  "text"}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   470
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   471
  \item [@{command "ML_val"} and @{command "ML_command"}] are
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   472
  diagnostic versions of @{command "ML"}, which means that the context
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   473
  may not be updated.  @{command "ML_val"} echos the bindings produced
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   474
  at the ML toplevel, but @{command "ML_command"} is silent.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   475
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   476
  \item [@{command "setup"}~@{text "text"}] changes the current theory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   477
  context by applying @{text "text"}, which refers to an ML expression
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   478
  of type @{ML_type "theory -> theory"}.  This enables to initialize
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   479
  any object-logic specific tools and packages written in ML, for
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   480
  example.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   481
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   482
  \item [@{command "method_setup"}~@{text "name = text description"}]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   483
  defines a proof method in the current theory.  The given @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   484
  "text"} has to be an ML expression of type @{ML_type "Args.src ->
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   485
  Proof.context -> Proof.method"}.  Parsing concrete method syntax
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   486
  from @{ML_type Args.src} input can be quite tedious in general.  The
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   487
  following simple examples are for methods without any explicit
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   488
  arguments, or a list of theorems, respectively.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   489
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   490
%FIXME proper antiquotations
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   491
{\footnotesize
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   492
\begin{verbatim}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   493
 Method.no_args (Method.METHOD (fn facts => foobar_tac))
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   494
 Method.thms_args (fn thms => Method.METHOD (fn facts => foobar_tac))
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   495
 Method.ctxt_args (fn ctxt => Method.METHOD (fn facts => foobar_tac))
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   496
 Method.thms_ctxt_args (fn thms => fn ctxt =>
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   497
    Method.METHOD (fn facts => foobar_tac))
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   498
\end{verbatim}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   499
}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   500
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   501
  Note that mere tactic emulations may ignore the @{text facts}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   502
  parameter above.  Proper proof methods would do something
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   503
  appropriate with the list of current facts, though.  Single-rule
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   504
  methods usually do strict forward-chaining (e.g.\ by using @{ML
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   505
  Drule.multi_resolves}), while automatic ones just insert the facts
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   506
  using @{ML Method.insert_tac} before applying the main tactic.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   507
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   508
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   509
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   510
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   511
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   512
subsection {* Syntax translation functions *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   513
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   514
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   515
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   516
    @{command_def "parse_ast_translation"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   517
    @{command_def "parse_translation"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   518
    @{command_def "print_translation"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   519
    @{command_def "typed_print_translation"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   520
    @{command_def "print_ast_translation"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   521
    @{command_def "token_translation"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   522
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   523
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   524
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   525
  ( 'parse\_ast\_translation' | 'parse\_translation' | 'print\_translation' |
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   526
    'typed\_print\_translation' | 'print\_ast\_translation' ) ('(advanced)')? text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   527
  ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   528
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   529
  'token\_translation' text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   530
  ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   531
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   532
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   533
  Syntax translation functions written in ML admit almost arbitrary
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   534
  manipulations of Isabelle's inner syntax.  Any of the above commands
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   535
  have a single \railqtok{text} argument that refers to an ML
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   536
  expression of appropriate type, which are as follows by default:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   537
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   538
%FIXME proper antiquotations
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   539
\begin{ttbox}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   540
val parse_ast_translation   : (string * (ast list -> ast)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   541
val parse_translation       : (string * (term list -> term)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   542
val print_translation       : (string * (term list -> term)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   543
val typed_print_translation :
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   544
  (string * (bool -> typ -> term list -> term)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   545
val print_ast_translation   : (string * (ast list -> ast)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   546
val token_translation       :
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   547
  (string * string * (string -> string * real)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   548
\end{ttbox}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   549
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   550
  If the @{text "(advanced)"} option is given, the corresponding
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   551
  translation functions may depend on the current theory or proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   552
  context.  This allows to implement advanced syntax mechanisms, as
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   553
  translations functions may refer to specific theory declarations or
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   554
  auxiliary proof data.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   555
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   556
  See also \cite[\S8]{isabelle-ref} for more information on the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   557
  general concept of syntax transformations in Isabelle.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   558
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   559
%FIXME proper antiquotations
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   560
\begin{ttbox}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   561
val parse_ast_translation:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   562
  (string * (Context.generic -> ast list -> ast)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   563
val parse_translation:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   564
  (string * (Context.generic -> term list -> term)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   565
val print_translation:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   566
  (string * (Context.generic -> term list -> term)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   567
val typed_print_translation:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   568
  (string * (Context.generic -> bool -> typ -> term list -> term)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   569
val print_ast_translation:
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   570
  (string * (Context.generic -> ast list -> ast)) list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   571
\end{ttbox}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   572
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   573
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   574
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   575
subsection {* Oracles *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   576
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   577
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   578
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   579
    @{command_def "oracle"} & : & \isartrans{theory}{theory} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   580
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   581
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   582
  The oracle interface promotes a given ML function @{ML_text
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   583
  "theory -> T -> term"} to @{ML_text "theory -> T -> thm"}, for some
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   584
  type @{ML_text T} given by the user.  This acts like an infinitary
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   585
  specification of axioms -- there is no internal check of the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   586
  correctness of the results!  The inference kernel records oracle
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   587
  invocations within the internal derivation object of theorems, and
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   588
  the pretty printer attaches ``@{text "[!]"}'' to indicate results
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   589
  that are not fully checked by Isabelle inferences.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   590
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   591
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   592
    'oracle' name '(' type ')' '=' text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   593
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   594
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   595
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   596
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   597
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   598
  \item [@{command "oracle"}~@{text "name (type) = text"}] turns the
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   599
  given ML expression @{text "text"} of type
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   600
  @{ML_text "theory ->"}~@{text "type"}~@{ML_text "-> term"} into an
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   601
  ML function of type
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   602
  @{ML_text "theory ->"}~@{text "type"}~@{ML_text "-> thm"}, which is
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   603
  bound to the global identifier @{ML_text name}.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   604
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   605
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   606
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   607
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   608
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   609
section {* Proof commands *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   610
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   611
subsection {* Markup commands \label{sec:markup-prf} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   612
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   613
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   614
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   615
    @{command_def "sect"} & : & \isartrans{proof}{proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   616
    @{command_def "subsect"} & : & \isartrans{proof}{proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   617
    @{command_def "subsubsect"} & : & \isartrans{proof}{proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   618
    @{command_def "txt"} & : & \isartrans{proof}{proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   619
    @{command_def "txt_raw"} & : & \isartrans{proof}{proof} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   620
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   621
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   622
  These markup commands for proof mode closely correspond to the ones
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   623
  of theory mode (see \S\ref{sec:markup-thy}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   624
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   625
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   626
    ('sect' | 'subsect' | 'subsubsect' | 'txt' | 'txt\_raw') text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   627
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   628
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   629
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   630
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   631
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   632
section {* Other commands *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   633
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   634
subsection {* Diagnostics *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   635
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   636
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   637
  \begin{matharray}{rcl}
26866
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   638
    @{command_def "pr"}@{text "\<^sup>*"} & : & \isarkeep{\cdot} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   639
    @{command_def "thm"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   640
    @{command_def "term"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   641
    @{command_def "prop"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   642
    @{command_def "typ"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   643
    @{command_def "prf"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   644
    @{command_def "full_prf"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   645
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   646
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   647
  These diagnostic commands assist interactive development.  Note that
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   648
  @{command undo} does not apply here, the theory or proof
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   649
  configuration is not changed.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   650
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   651
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   652
    'pr' modes? nat? (',' nat)?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   653
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   654
    'thm' modes? thmrefs
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   655
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   656
    'term' modes? term
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   657
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   658
    'prop' modes? prop
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   659
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   660
    'typ' modes? type
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   661
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   662
    'prf' modes? thmrefs?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   663
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   664
    'full\_prf' modes? thmrefs?
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   665
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   666
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   667
    modes: '(' (name + ) ')'
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   668
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   669
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   670
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   671
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   672
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   673
  \item [@{command "pr"}~@{text "goals, prems"}] prints the current
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   674
  proof state (if present), including the proof context, current facts
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   675
  and goals.  The optional limit arguments affect the number of goals
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   676
  and premises to be displayed, which is initially 10 for both.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   677
  Omitting limit values leaves the current setting unchanged.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   678
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   679
  \item [@{command "thm"}~@{text "a\<^sub>1 \<dots> a\<^sub>n"}] retrieves
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   680
  theorems from the current theory or proof context.  Note that any
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   681
  attributes included in the theorem specifications are applied to a
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   682
  temporary context derived from the current theory or proof; the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   683
  result is discarded, i.e.\ attributes involved in @{text "a\<^sub>1,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   684
  \<dots>, a\<^sub>n"} do not have any permanent effect.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   685
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   686
  \item [@{command "term"}~@{text t} and @{command "prop"}~@{text \<phi>}]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   687
  read, type-check and print terms or propositions according to the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   688
  current theory or proof context; the inferred type of @{text t} is
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   689
  output as well.  Note that these commands are also useful in
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   690
  inspecting the current environment of term abbreviations.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   691
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   692
  \item [@{command "typ"}~@{text \<tau>}] reads and prints types of the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   693
  meta-logic according to the current theory or proof context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   694
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   695
  \item [@{command "prf"}] displays the (compact) proof term of the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   696
  current proof state (if present), or of the given theorems. Note
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   697
  that this requires proof terms to be switched on for the current
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   698
  object logic (see the ``Proof terms'' section of the Isabelle
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   699
  reference manual for information on how to do this).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   700
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   701
  \item [@{command "full_prf"}] is like @{command "prf"}, but displays
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   702
  the full proof term, i.e.\ also displays information omitted in the
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   703
  compact proof term, which is denoted by ``@{text _}'' placeholders
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   704
  there.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   705
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   706
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   707
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   708
  All of the diagnostic commands above admit a list of @{text modes}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   709
  to be specified, which is appended to the current print mode (see
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   710
  also \cite{isabelle-ref}).  Thus the output behavior may be modified
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   711
  according particular print mode features.  For example, @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   712
  "pr"}~@{text "(latex xsymbols symbols)"} would print the current
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   713
  proof state with mathematical symbols and special characters
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   714
  represented in {\LaTeX} source, according to the Isabelle style
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   715
  \cite{isabelle-sys}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   716
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   717
  Note that antiquotations (cf.\ \secref{sec:antiq}) provide a more
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   718
  systematic way to include formal items into the printed text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   719
  document.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   720
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   721
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   722
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   723
subsection {* Inspecting the context *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   724
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   725
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   726
  \begin{matharray}{rcl}
26866
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   727
    @{command_def "print_commands"}@{text "\<^sup>*"} & : & \isarkeep{\cdot} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   728
    @{command_def "print_theory"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   729
    @{command_def "print_syntax"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   730
    @{command_def "print_methods"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   731
    @{command_def "print_attributes"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   732
    @{command_def "print_theorems"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   733
    @{command_def "find_theorems"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
26894
1120f6cc10b0 proper checking of various Isar elements;
wenzelm
parents: 26870
diff changeset
   734
    @{command_def "thm_deps"}@{text "\<^sup>*"} & : & \isarkeep{theory~|~proof} \\
26866
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   735
    @{command_def "print_facts"}@{text "\<^sup>*"} & : & \isarkeep{proof} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   736
    @{command_def "print_binds"}@{text "\<^sup>*"} & : & \isarkeep{proof} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   737
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   738
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   739
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   740
    'print\_theory' ( '!'?)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   741
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   742
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   743
    'find\_theorems' (('(' (nat)? ('with\_dups')? ')')?) (criterion *)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   744
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   745
    criterion: ('-'?) ('name' ':' nameref | 'intro' | 'elim' | 'dest' |
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   746
      'simp' ':' term | term)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   747
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   748
    'thm\_deps' thmrefs
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   749
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   750
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   751
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   752
  These commands print certain parts of the theory and proof context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   753
  Note that there are some further ones available, such as for the set
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   754
  of rules declared for simplifications.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   755
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   756
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   757
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   758
  \item [@{command "print_commands"}] prints Isabelle's outer theory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   759
  syntax, including keywords and command.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   760
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   761
  \item [@{command "print_theory"}] prints the main logical content of
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   762
  the theory context; the ``@{text "!"}'' option indicates extra
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   763
  verbosity.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   764
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   765
  \item [@{command "print_syntax"}] prints the inner syntax of types
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   766
  and terms, depending on the current context.  The output can be very
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   767
  verbose, including grammar tables and syntax translation rules.  See
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   768
  \cite[\S7, \S8]{isabelle-ref} for further information on Isabelle's
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   769
  inner syntax.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   770
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   771
  \item [@{command "print_methods"}] prints all proof methods
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   772
  available in the current theory context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   773
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   774
  \item [@{command "print_attributes"}] prints all attributes
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   775
  available in the current theory context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   776
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   777
  \item [@{command "print_theorems"}] prints theorems resulting from
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   778
  the last command.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   779
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   780
  \item [@{command "find_theorems"}~@{text criteria}] retrieves facts
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   781
  from the theory or proof context matching all of given search
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   782
  criteria.  The criterion @{text "name: p"} selects all theorems
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   783
  whose fully qualified name matches pattern @{text p}, which may
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   784
  contain ``@{text "*"}'' wildcards.  The criteria @{text intro},
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   785
  @{text elim}, and @{text dest} select theorems that match the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   786
  current goal as introduction, elimination or destruction rules,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   787
  respectively.  The criterion @{text "simp: t"} selects all rewrite
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   788
  rules whose left-hand side matches the given term.  The criterion
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   789
  term @{text t} selects all theorems that contain the pattern @{text
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   790
  t} -- as usual, patterns may contain occurrences of the dummy
26777
134529bc72db misc tuning;
wenzelm
parents: 26767
diff changeset
   791
  ``@{text _}'', schematic variables, and type constraints.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   792
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   793
  Criteria can be preceded by ``@{text "-"}'' to select theorems that
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   794
  do \emph{not} match. Note that giving the empty list of criteria
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   795
  yields \emph{all} currently known facts.  An optional limit for the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   796
  number of printed facts may be given; the default is 40.  By
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   797
  default, duplicates are removed from the search result. Use
26894
1120f6cc10b0 proper checking of various Isar elements;
wenzelm
parents: 26870
diff changeset
   798
  @{text with_dups} to display duplicates.
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   799
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   800
  \item [@{command "thm_deps"}~@{text "a\<^sub>1 \<dots> a\<^sub>n"}]
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   801
  visualizes dependencies of facts, using Isabelle's graph browser
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   802
  tool (see also \cite{isabelle-sys}).
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   803
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   804
  \item [@{command "print_facts"}] prints all local facts of the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   805
  current context, both named and unnamed ones.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   806
  
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   807
  \item [@{command "print_binds"}] prints all term abbreviations
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   808
  present in the context.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   809
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   810
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   811
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   812
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   813
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   814
subsection {* History commands \label{sec:history} *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   815
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   816
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   817
  \begin{matharray}{rcl}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   818
    @{command_def "undo"}^{{ * }{ * }} & : & \isarkeep{\cdot} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   819
    @{command_def "redo"}^{{ * }{ * }} & : & \isarkeep{\cdot} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   820
    @{command_def "kill"}^{{ * }{ * }} & : & \isarkeep{\cdot} \\
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   821
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   822
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   823
  The Isabelle/Isar top-level maintains a two-stage history, for
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   824
  theory and proof state transformation.  Basically, any command can
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   825
  be undone using @{command "undo"}, excluding mere diagnostic
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   826
  elements.  Its effect may be revoked via @{command "redo"}, unless
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   827
  the corresponding @{command "undo"} step has crossed the beginning
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   828
  of a proof or theory.  The @{command "kill"} command aborts the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   829
  current history node altogether, discontinuing a proof or even the
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   830
  whole theory.  This operation is \emph{not} undo-able.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   831
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   832
  \begin{warn}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   833
    History commands should never be used with user interfaces such as
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   834
    Proof~General \cite{proofgeneral,Aspinall:TACAS:2000}, which takes
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   835
    care of stepping forth and back itself.  Interfering by manual
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   836
    @{command "undo"}, @{command "redo"}, or even @{command "kill"}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   837
    commands would quickly result in utter confusion.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   838
  \end{warn}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   839
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   840
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   841
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   842
subsection {* System operations *}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   843
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   844
text {*
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   845
  \begin{matharray}{rcl}
26866
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   846
    @{command_def "cd"}@{text "\<^sup>*"} & : & \isarkeep{\cdot} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   847
    @{command_def "pwd"}@{text "\<^sup>*"} & : & \isarkeep{\cdot} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   848
    @{command_def "use_thy"}@{text "\<^sup>*"} & : & \isarkeep{\cdot} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   849
    @{command_def "display_drafts"}@{text "\<^sup>*"} & : & \isarkeep{\cdot} \\
3cff7b336c75 proper antiquotations for commands;
wenzelm
parents: 26852
diff changeset
   850
    @{command_def "print_drafts"}@{text "\<^sup>*"} & : & \isarkeep{\cdot} \\
26767
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   851
  \end{matharray}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   852
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   853
  \begin{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   854
    ('cd' | 'use\_thy' | 'update\_thy') name
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   855
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   856
    ('display\_drafts' | 'print\_drafts') (name +)
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   857
    ;
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   858
  \end{rail}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   859
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   860
  \begin{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   861
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   862
  \item [@{command "cd"}~@{text path}] changes the current directory
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   863
  of the Isabelle process.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   864
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   865
  \item [@{command "pwd"}] prints the current working directory.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   866
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   867
  \item [@{command "use_thy"}~@{text A}] preload theory @{text A}.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   868
  These system commands are scarcely used when working interactively,
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   869
  since loading of theories is done automatically as required.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   870
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   871
  \item [@{command "display_drafts"}~@{text paths} and @{command
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   872
  "print_drafts"}~@{text paths}] perform simple output of a given list
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   873
  of raw source files.  Only those symbols that do not require
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   874
  additional {\LaTeX} packages are displayed properly, everything else
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   875
  is left verbatim.
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   876
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   877
  \end{descr}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   878
*}
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   879
cc127cc0951b converted pure.tex to Thy/pure.thy;
wenzelm
parents:
diff changeset
   880
end