doc-src/IsarRef/Thy/Generic.thy
author wenzelm
Thu, 13 Nov 2008 21:45:40 +0100
changeset 28761 9ec4482c9201
parent 28760 cbc435f7b16b
child 28764 b65194fe4434
permissions -rw-r--r--
updated/refined types of Isar language elements, removed special LaTeX macros;
wenzelm@26782
     1
(* $Id$ *)
wenzelm@26782
     2
wenzelm@26782
     3
theory Generic
wenzelm@26894
     4
imports Main
wenzelm@26782
     5
begin
wenzelm@26782
     6
wenzelm@26782
     7
chapter {* Generic tools and packages \label{ch:gen-tools} *}
wenzelm@26782
     8
wenzelm@27040
     9
section {* Configuration options *}
wenzelm@26782
    10
wenzelm@26782
    11
text {*
wenzelm@26782
    12
  Isabelle/Pure maintains a record of named configuration options
wenzelm@26782
    13
  within the theory or proof context, with values of type @{ML_type
wenzelm@26782
    14
  bool}, @{ML_type int}, or @{ML_type string}.  Tools may declare
wenzelm@26782
    15
  options in ML, and then refer to these values (relative to the
wenzelm@26782
    16
  context).  Thus global reference variables are easily avoided.  The
wenzelm@26782
    17
  user may change the value of a configuration option by means of an
wenzelm@26782
    18
  associated attribute of the same name.  This form of context
wenzelm@26782
    19
  declaration works particularly well with commands such as @{command
wenzelm@26782
    20
  "declare"} or @{command "using"}.
wenzelm@26782
    21
wenzelm@26782
    22
  For historical reasons, some tools cannot take the full proof
wenzelm@26782
    23
  context into account and merely refer to the background theory.
wenzelm@26782
    24
  This is accommodated by configuration options being declared as
wenzelm@26782
    25
  ``global'', which may not be changed within a local context.
wenzelm@26782
    26
wenzelm@26782
    27
  \begin{matharray}{rcll}
wenzelm@28761
    28
    @{command_def "print_configs"} & : & @{text "context \<rightarrow>"} \\
wenzelm@26782
    29
  \end{matharray}
wenzelm@26782
    30
wenzelm@26782
    31
  \begin{rail}
wenzelm@26782
    32
    name ('=' ('true' | 'false' | int | name))?
wenzelm@26782
    33
  \end{rail}
wenzelm@26782
    34
wenzelm@28760
    35
  \begin{description}
wenzelm@26782
    36
  
wenzelm@28760
    37
  \item @{command "print_configs"} prints the available configuration
wenzelm@28760
    38
  options, with names, types, and current values.
wenzelm@26782
    39
  
wenzelm@28760
    40
  \item @{text "name = value"} as an attribute expression modifies the
wenzelm@28760
    41
  named option, with the syntax of the value depending on the option's
wenzelm@28760
    42
  type.  For @{ML_type bool} the default value is @{text true}.  Any
wenzelm@28760
    43
  attempt to change a global option in a local context is ignored.
wenzelm@26782
    44
wenzelm@28760
    45
  \end{description}
wenzelm@26782
    46
*}
wenzelm@26782
    47
wenzelm@26782
    48
wenzelm@27040
    49
section {* Basic proof tools *}
wenzelm@26782
    50
wenzelm@26782
    51
subsection {* Miscellaneous methods and attributes \label{sec:misc-meth-att} *}
wenzelm@26782
    52
wenzelm@26782
    53
text {*
wenzelm@26782
    54
  \begin{matharray}{rcl}
wenzelm@28761
    55
    @{method_def unfold} & : & @{text method} \\
wenzelm@28761
    56
    @{method_def fold} & : & @{text method} \\
wenzelm@28761
    57
    @{method_def insert} & : & @{text method} \\[0.5ex]
wenzelm@28761
    58
    @{method_def erule}@{text "\<^sup>*"} & : & @{text method} \\
wenzelm@28761
    59
    @{method_def drule}@{text "\<^sup>*"} & : & @{text method} \\
wenzelm@28761
    60
    @{method_def frule}@{text "\<^sup>*"} & : & @{text method} \\
wenzelm@28761
    61
    @{method_def succeed} & : & @{text method} \\
wenzelm@28761
    62
    @{method_def fail} & : & @{text method} \\
wenzelm@26782
    63
  \end{matharray}
wenzelm@26782
    64
wenzelm@26782
    65
  \begin{rail}
wenzelm@26782
    66
    ('fold' | 'unfold' | 'insert') thmrefs
wenzelm@26782
    67
    ;
wenzelm@26782
    68
    ('erule' | 'drule' | 'frule') ('('nat')')? thmrefs
wenzelm@26782
    69
    ;
wenzelm@26782
    70
  \end{rail}
wenzelm@26782
    71
wenzelm@28760
    72
  \begin{description}
wenzelm@26782
    73
  
wenzelm@28760
    74
  \item @{method unfold}~@{text "a\<^sub>1 \<dots> a\<^sub>n"} and @{method fold}~@{text
wenzelm@28760
    75
  "a\<^sub>1 \<dots> a\<^sub>n"} expand (or fold back) the given definitions throughout
wenzelm@28760
    76
  all goals; any chained facts provided are inserted into the goal and
wenzelm@28760
    77
  subject to rewriting as well.
wenzelm@26782
    78
wenzelm@28760
    79
  \item @{method insert}~@{text "a\<^sub>1 \<dots> a\<^sub>n"} inserts theorems as facts
wenzelm@28760
    80
  into all goals of the proof state.  Note that current facts
wenzelm@28760
    81
  indicated for forward chaining are ignored.
wenzelm@26782
    82
wenzelm@28760
    83
  \item @{method erule}~@{text "a\<^sub>1 \<dots> a\<^sub>n"}, @{method drule}~@{text "a\<^sub>1
wenzelm@28760
    84
  \<dots> a\<^sub>n"}, and @{method frule}~@{text "a\<^sub>1 \<dots> a\<^sub>n"} are similar to the
wenzelm@28760
    85
  basic @{method rule} method (see \secref{sec:pure-meth-att}), but
wenzelm@28760
    86
  apply rules by elim-resolution, destruct-resolution, and
wenzelm@28760
    87
  forward-resolution, respectively \cite{isabelle-ref}.  The optional
wenzelm@28760
    88
  natural number argument (default 0) specifies additional assumption
wenzelm@28760
    89
  steps to be performed here.
wenzelm@26782
    90
wenzelm@26782
    91
  Note that these methods are improper ones, mainly serving for
wenzelm@26782
    92
  experimentation and tactic script emulation.  Different modes of
wenzelm@26782
    93
  basic rule application are usually expressed in Isar at the proof
wenzelm@26782
    94
  language level, rather than via implicit proof state manipulations.
wenzelm@26782
    95
  For example, a proper single-step elimination would be done using
wenzelm@26782
    96
  the plain @{method rule} method, with forward chaining of current
wenzelm@26782
    97
  facts.
wenzelm@26782
    98
wenzelm@28760
    99
  \item @{method succeed} yields a single (unchanged) result; it is
wenzelm@26782
   100
  the identity of the ``@{text ","}'' method combinator (cf.\
wenzelm@28754
   101
  \secref{sec:proof-meth}).
wenzelm@26782
   102
wenzelm@28760
   103
  \item @{method fail} yields an empty result sequence; it is the
wenzelm@26782
   104
  identity of the ``@{text "|"}'' method combinator (cf.\
wenzelm@28754
   105
  \secref{sec:proof-meth}).
wenzelm@26782
   106
wenzelm@28760
   107
  \end{description}
wenzelm@26782
   108
wenzelm@26782
   109
  \begin{matharray}{rcl}
wenzelm@28761
   110
    @{attribute_def tagged} & : & @{text attribute} \\
wenzelm@28761
   111
    @{attribute_def untagged} & : & @{text attribute} \\[0.5ex]
wenzelm@28761
   112
    @{attribute_def THEN} & : & @{text attribute} \\
wenzelm@28761
   113
    @{attribute_def COMP} & : & @{text attribute} \\[0.5ex]
wenzelm@28761
   114
    @{attribute_def unfolded} & : & @{text attribute} \\
wenzelm@28761
   115
    @{attribute_def folded} & : & @{text attribute} \\[0.5ex]
wenzelm@28761
   116
    @{attribute_def rotated} & : & @{text attribute} \\
wenzelm@28761
   117
    @{attribute_def (Pure) elim_format} & : & @{text attribute} \\
wenzelm@28761
   118
    @{attribute_def standard}@{text "\<^sup>*"} & : & @{text attribute} \\
wenzelm@28761
   119
    @{attribute_def no_vars}@{text "\<^sup>*"} & : & @{text attribute} \\
wenzelm@26782
   120
  \end{matharray}
wenzelm@26782
   121
wenzelm@26782
   122
  \begin{rail}
wenzelm@26782
   123
    'tagged' nameref
wenzelm@26782
   124
    ;
wenzelm@26782
   125
    'untagged' name
wenzelm@26782
   126
    ;
wenzelm@26782
   127
    ('THEN' | 'COMP') ('[' nat ']')? thmref
wenzelm@26782
   128
    ;
wenzelm@26782
   129
    ('unfolded' | 'folded') thmrefs
wenzelm@26782
   130
    ;
wenzelm@26782
   131
    'rotated' ( int )?
wenzelm@26782
   132
  \end{rail}
wenzelm@26782
   133
wenzelm@28760
   134
  \begin{description}
wenzelm@26782
   135
wenzelm@28760
   136
  \item @{attribute tagged}~@{text "name arg"} and @{attribute
wenzelm@28760
   137
  untagged}~@{text name} add and remove \emph{tags} of some theorem.
wenzelm@26782
   138
  Tags may be any list of string pairs that serve as formal comment.
wenzelm@26782
   139
  The first string is considered the tag name, the second its
wenzelm@26782
   140
  argument.  Note that @{attribute untagged} removes any tags of the
wenzelm@26782
   141
  same name.
wenzelm@26782
   142
wenzelm@28760
   143
  \item @{attribute THEN}~@{text a} and @{attribute COMP}~@{text a}
wenzelm@26782
   144
  compose rules by resolution.  @{attribute THEN} resolves with the
wenzelm@26782
   145
  first premise of @{text a} (an alternative position may be also
wenzelm@26782
   146
  specified); the @{attribute COMP} version skips the automatic
wenzelm@28761
   147
  lifting process that is normally intended (cf.\ @{ML [source=false]
wenzelm@28761
   148
  "op RS"} and @{ML [source=false] "op COMP"} in
wenzelm@28761
   149
  \cite[\S5]{isabelle-ref}).
wenzelm@26782
   150
  
wenzelm@28760
   151
  \item @{attribute unfolded}~@{text "a\<^sub>1 \<dots> a\<^sub>n"} and @{attribute
wenzelm@28760
   152
  folded}~@{text "a\<^sub>1 \<dots> a\<^sub>n"} expand and fold back again the given
wenzelm@28760
   153
  definitions throughout a rule.
wenzelm@26782
   154
wenzelm@28760
   155
  \item @{attribute rotated}~@{text n} rotate the premises of a
wenzelm@26782
   156
  theorem by @{text n} (default 1).
wenzelm@26782
   157
wenzelm@28760
   158
  \item @{attribute (Pure) elim_format} turns a destruction rule into
wenzelm@28760
   159
  elimination rule format, by resolving with the rule @{prop "PROP A \<Longrightarrow>
wenzelm@28760
   160
  (PROP A \<Longrightarrow> PROP B) \<Longrightarrow> PROP B"}.
wenzelm@26782
   161
  
wenzelm@26782
   162
  Note that the Classical Reasoner (\secref{sec:classical}) provides
wenzelm@26782
   163
  its own version of this operation.
wenzelm@26782
   164
wenzelm@28760
   165
  \item @{attribute standard} puts a theorem into the standard form of
wenzelm@28760
   166
  object-rules at the outermost theory level.  Note that this
wenzelm@26782
   167
  operation violates the local proof context (including active
wenzelm@26782
   168
  locales).
wenzelm@26782
   169
wenzelm@28760
   170
  \item @{attribute no_vars} replaces schematic variables by free
wenzelm@26782
   171
  ones; this is mainly for tuning output of pretty printed theorems.
wenzelm@26782
   172
wenzelm@28760
   173
  \end{description}
wenzelm@26782
   174
*}
wenzelm@26782
   175
wenzelm@26782
   176
wenzelm@27044
   177
subsection {* Low-level equational reasoning *}
wenzelm@27044
   178
wenzelm@27044
   179
text {*
wenzelm@27044
   180
  \begin{matharray}{rcl}
wenzelm@28761
   181
    @{method_def subst} & : & @{text method} \\
wenzelm@28761
   182
    @{method_def hypsubst} & : & @{text method} \\
wenzelm@28761
   183
    @{method_def split} & : & @{text method} \\
wenzelm@27044
   184
  \end{matharray}
wenzelm@27044
   185
wenzelm@27044
   186
  \begin{rail}
wenzelm@27044
   187
    'subst' ('(' 'asm' ')')? ('(' (nat+) ')')? thmref
wenzelm@27044
   188
    ;
wenzelm@27044
   189
    'split' ('(' 'asm' ')')? thmrefs
wenzelm@27044
   190
    ;
wenzelm@27044
   191
  \end{rail}
wenzelm@27044
   192
wenzelm@27044
   193
  These methods provide low-level facilities for equational reasoning
wenzelm@27044
   194
  that are intended for specialized applications only.  Normally,
wenzelm@27044
   195
  single step calculations would be performed in a structured text
wenzelm@27044
   196
  (see also \secref{sec:calculation}), while the Simplifier methods
wenzelm@27044
   197
  provide the canonical way for automated normalization (see
wenzelm@27044
   198
  \secref{sec:simplifier}).
wenzelm@27044
   199
wenzelm@28760
   200
  \begin{description}
wenzelm@27044
   201
wenzelm@28760
   202
  \item @{method subst}~@{text eq} performs a single substitution step
wenzelm@28760
   203
  using rule @{text eq}, which may be either a meta or object
wenzelm@27044
   204
  equality.
wenzelm@27044
   205
wenzelm@28760
   206
  \item @{method subst}~@{text "(asm) eq"} substitutes in an
wenzelm@27044
   207
  assumption.
wenzelm@27044
   208
wenzelm@28760
   209
  \item @{method subst}~@{text "(i \<dots> j) eq"} performs several
wenzelm@27044
   210
  substitutions in the conclusion. The numbers @{text i} to @{text j}
wenzelm@27044
   211
  indicate the positions to substitute at.  Positions are ordered from
wenzelm@27044
   212
  the top of the term tree moving down from left to right. For
wenzelm@27044
   213
  example, in @{text "(a + b) + (c + d)"} there are three positions
wenzelm@28760
   214
  where commutativity of @{text "+"} is applicable: 1 refers to @{text
wenzelm@28760
   215
  "a + b"}, 2 to the whole term, and 3 to @{text "c + d"}.
wenzelm@27044
   216
wenzelm@27044
   217
  If the positions in the list @{text "(i \<dots> j)"} are non-overlapping
wenzelm@27044
   218
  (e.g.\ @{text "(2 3)"} in @{text "(a + b) + (c + d)"}) you may
wenzelm@27044
   219
  assume all substitutions are performed simultaneously.  Otherwise
wenzelm@27044
   220
  the behaviour of @{text subst} is not specified.
wenzelm@27044
   221
wenzelm@28760
   222
  \item @{method subst}~@{text "(asm) (i \<dots> j) eq"} performs the
wenzelm@27071
   223
  substitutions in the assumptions. The positions refer to the
wenzelm@27071
   224
  assumptions in order from left to right.  For example, given in a
wenzelm@27071
   225
  goal of the form @{text "P (a + b) \<Longrightarrow> P (c + d) \<Longrightarrow> \<dots>"}, position 1 of
wenzelm@27071
   226
  commutativity of @{text "+"} is the subterm @{text "a + b"} and
wenzelm@27071
   227
  position 2 is the subterm @{text "c + d"}.
wenzelm@27044
   228
wenzelm@28760
   229
  \item @{method hypsubst} performs substitution using some
wenzelm@27044
   230
  assumption; this only works for equations of the form @{text "x =
wenzelm@27044
   231
  t"} where @{text x} is a free or bound variable.
wenzelm@27044
   232
wenzelm@28760
   233
  \item @{method split}~@{text "a\<^sub>1 \<dots> a\<^sub>n"} performs single-step case
wenzelm@28760
   234
  splitting using the given rules.  By default, splitting is performed
wenzelm@28760
   235
  in the conclusion of a goal; the @{text "(asm)"} option indicates to
wenzelm@28760
   236
  operate on assumptions instead.
wenzelm@27044
   237
  
wenzelm@27044
   238
  Note that the @{method simp} method already involves repeated
wenzelm@27044
   239
  application of split rules as declared in the current context.
wenzelm@27044
   240
wenzelm@28760
   241
  \end{description}
wenzelm@27044
   242
*}
wenzelm@27044
   243
wenzelm@27044
   244
wenzelm@26782
   245
subsection {* Further tactic emulations \label{sec:tactics} *}
wenzelm@26782
   246
wenzelm@26782
   247
text {*
wenzelm@26782
   248
  The following improper proof methods emulate traditional tactics.
wenzelm@26782
   249
  These admit direct access to the goal state, which is normally
wenzelm@26782
   250
  considered harmful!  In particular, this may involve both numbered
wenzelm@26782
   251
  goal addressing (default 1), and dynamic instantiation within the
wenzelm@26782
   252
  scope of some subgoal.
wenzelm@26782
   253
wenzelm@26782
   254
  \begin{warn}
wenzelm@26782
   255
    Dynamic instantiations refer to universally quantified parameters
wenzelm@26782
   256
    of a subgoal (the dynamic context) rather than fixed variables and
wenzelm@26782
   257
    term abbreviations of a (static) Isar context.
wenzelm@26782
   258
  \end{warn}
wenzelm@26782
   259
wenzelm@26782
   260
  Tactic emulation methods, unlike their ML counterparts, admit
wenzelm@26782
   261
  simultaneous instantiation from both dynamic and static contexts.
wenzelm@26782
   262
  If names occur in both contexts goal parameters hide locally fixed
wenzelm@26782
   263
  variables.  Likewise, schematic variables refer to term
wenzelm@26782
   264
  abbreviations, if present in the static context.  Otherwise the
wenzelm@26782
   265
  schematic variable is interpreted as a schematic variable and left
wenzelm@26782
   266
  to be solved by unification with certain parts of the subgoal.
wenzelm@26782
   267
wenzelm@26782
   268
  Note that the tactic emulation proof methods in Isabelle/Isar are
wenzelm@26782
   269
  consistently named @{text foo_tac}.  Note also that variable names
wenzelm@26782
   270
  occurring on left hand sides of instantiations must be preceded by a
wenzelm@26782
   271
  question mark if they coincide with a keyword or contain dots.  This
wenzelm@26782
   272
  is consistent with the attribute @{attribute "where"} (see
wenzelm@26782
   273
  \secref{sec:pure-meth-att}).
wenzelm@26782
   274
wenzelm@26782
   275
  \begin{matharray}{rcl}
wenzelm@28761
   276
    @{method_def rule_tac}@{text "\<^sup>*"} & : & @{text method} \\
wenzelm@28761
   277
    @{method_def erule_tac}@{text "\<^sup>*"} & : & @{text method} \\
wenzelm@28761
   278
    @{method_def drule_tac}@{text "\<^sup>*"} & : & @{text method} \\
wenzelm@28761
   279
    @{method_def frule_tac}@{text "\<^sup>*"} & : & @{text method} \\
wenzelm@28761
   280
    @{method_def cut_tac}@{text "\<^sup>*"} & : & @{text method} \\
wenzelm@28761
   281
    @{method_def thin_tac}@{text "\<^sup>*"} & : & @{text method} \\
wenzelm@28761
   282
    @{method_def subgoal_tac}@{text "\<^sup>*"} & : & @{text method} \\
wenzelm@28761
   283
    @{method_def rename_tac}@{text "\<^sup>*"} & : & @{text method} \\
wenzelm@28761
   284
    @{method_def rotate_tac}@{text "\<^sup>*"} & : & @{text method} \\
wenzelm@28761
   285
    @{method_def tactic}@{text "\<^sup>*"} & : & @{text method} \\
wenzelm@28761
   286
    @{method_def raw_tactic}@{text "\<^sup>*"} & : & @{text method} \\
wenzelm@26782
   287
  \end{matharray}
wenzelm@26782
   288
wenzelm@26782
   289
  \begin{rail}
wenzelm@26782
   290
    ( 'rule\_tac' | 'erule\_tac' | 'drule\_tac' | 'frule\_tac' | 'cut\_tac' | 'thin\_tac' ) goalspec?
wenzelm@26782
   291
    ( insts thmref | thmrefs )
wenzelm@26782
   292
    ;
wenzelm@26782
   293
    'subgoal\_tac' goalspec? (prop +)
wenzelm@26782
   294
    ;
wenzelm@26782
   295
    'rename\_tac' goalspec? (name +)
wenzelm@26782
   296
    ;
wenzelm@26782
   297
    'rotate\_tac' goalspec? int?
wenzelm@26782
   298
    ;
wenzelm@27223
   299
    ('tactic' | 'raw_tactic') text
wenzelm@26782
   300
    ;
wenzelm@26782
   301
wenzelm@26782
   302
    insts: ((name '=' term) + 'and') 'in'
wenzelm@26782
   303
    ;
wenzelm@26782
   304
  \end{rail}
wenzelm@26782
   305
wenzelm@28760
   306
\begin{description}
wenzelm@26782
   307
wenzelm@28760
   308
  \item @{method rule_tac} etc. do resolution of rules with explicit
wenzelm@26782
   309
  instantiation.  This works the same way as the ML tactics @{ML
wenzelm@27239
   310
  res_inst_tac} etc. (see \cite[\S3]{isabelle-ref})
wenzelm@26782
   311
wenzelm@26782
   312
  Multiple rules may be only given if there is no instantiation; then
wenzelm@26782
   313
  @{method rule_tac} is the same as @{ML resolve_tac} in ML (see
wenzelm@26782
   314
  \cite[\S3]{isabelle-ref}).
wenzelm@26782
   315
wenzelm@28760
   316
  \item @{method cut_tac} inserts facts into the proof state as
wenzelm@27209
   317
  assumption of a subgoal, see also @{ML Tactic.cut_facts_tac} in
wenzelm@26782
   318
  \cite[\S3]{isabelle-ref}.  Note that the scope of schematic
wenzelm@26782
   319
  variables is spread over the main goal statement.  Instantiations
wenzelm@28760
   320
  may be given as well, see also ML tactic @{ML cut_inst_tac} in
wenzelm@27209
   321
  \cite[\S3]{isabelle-ref}.
wenzelm@26782
   322
wenzelm@28760
   323
  \item @{method thin_tac}~@{text \<phi>} deletes the specified assumption
wenzelm@28760
   324
  from a subgoal; note that @{text \<phi>} may contain schematic variables.
wenzelm@28760
   325
  See also @{ML thin_tac} in \cite[\S3]{isabelle-ref}.
wenzelm@28760
   326
wenzelm@28760
   327
  \item @{method subgoal_tac}~@{text \<phi>} adds @{text \<phi>} as an
wenzelm@27239
   328
  assumption to a subgoal.  See also @{ML subgoal_tac} and @{ML
wenzelm@27239
   329
  subgoals_tac} in \cite[\S3]{isabelle-ref}.
wenzelm@26782
   330
wenzelm@28760
   331
  \item @{method rename_tac}~@{text "x\<^sub>1 \<dots> x\<^sub>n"} renames parameters of a
wenzelm@28760
   332
  goal according to the list @{text "x\<^sub>1, \<dots>, x\<^sub>n"}, which refers to the
wenzelm@28760
   333
  \emph{suffix} of variables.
wenzelm@26782
   334
wenzelm@28760
   335
  \item @{method rotate_tac}~@{text n} rotates the assumptions of a
wenzelm@26782
   336
  goal by @{text n} positions: from right to left if @{text n} is
wenzelm@26782
   337
  positive, and from left to right if @{text n} is negative; the
wenzelm@26782
   338
  default value is 1.  See also @{ML rotate_tac} in
wenzelm@26782
   339
  \cite[\S3]{isabelle-ref}.
wenzelm@26782
   340
wenzelm@28760
   341
  \item @{method tactic}~@{text "text"} produces a proof method from
wenzelm@26782
   342
  any ML text of type @{ML_type tactic}.  Apart from the usual ML
wenzelm@27223
   343
  environment and the current proof context, the ML code may refer to
wenzelm@27223
   344
  the locally bound values @{ML_text facts}, which indicates any
wenzelm@27223
   345
  current facts used for forward-chaining.
wenzelm@26782
   346
wenzelm@28760
   347
  \item @{method raw_tactic} is similar to @{method tactic}, but
wenzelm@27223
   348
  presents the goal state in its raw internal form, where simultaneous
wenzelm@27223
   349
  subgoals appear as conjunction of the logical framework instead of
wenzelm@27223
   350
  the usual split into several subgoals.  While feature this is useful
wenzelm@27223
   351
  for debugging of complex method definitions, it should not never
wenzelm@27223
   352
  appear in production theories.
wenzelm@26782
   353
wenzelm@28760
   354
  \end{description}
wenzelm@26782
   355
*}
wenzelm@26782
   356
wenzelm@26782
   357
wenzelm@27040
   358
section {* The Simplifier \label{sec:simplifier} *}
wenzelm@26782
   359
wenzelm@27040
   360
subsection {* Simplification methods *}
wenzelm@26782
   361
wenzelm@26782
   362
text {*
wenzelm@26782
   363
  \begin{matharray}{rcl}
wenzelm@28761
   364
    @{method_def simp} & : & @{text method} \\
wenzelm@28761
   365
    @{method_def simp_all} & : & @{text method} \\
wenzelm@26782
   366
  \end{matharray}
wenzelm@26782
   367
wenzelm@26782
   368
  \indexouternonterm{simpmod}
wenzelm@26782
   369
  \begin{rail}
wenzelm@26782
   370
    ('simp' | 'simp\_all') ('!' ?) opt? (simpmod *)
wenzelm@26782
   371
    ;
wenzelm@26782
   372
wenzelm@27092
   373
    opt: '(' ('no\_asm' | 'no\_asm\_simp' | 'no\_asm\_use' | 'asm\_lr' ) ')'
wenzelm@26782
   374
    ;
wenzelm@26782
   375
    simpmod: ('add' | 'del' | 'only' | 'cong' (() | 'add' | 'del') |
wenzelm@26782
   376
      'split' (() | 'add' | 'del')) ':' thmrefs
wenzelm@26782
   377
    ;
wenzelm@26782
   378
  \end{rail}
wenzelm@26782
   379
wenzelm@28760
   380
  \begin{description}
wenzelm@26782
   381
wenzelm@28760
   382
  \item @{method simp} invokes the Simplifier, after declaring
wenzelm@26782
   383
  additional rules according to the arguments given.  Note that the
wenzelm@26782
   384
  \railtterm{only} modifier first removes all other rewrite rules,
wenzelm@26782
   385
  congruences, and looper tactics (including splits), and then behaves
wenzelm@26782
   386
  like \railtterm{add}.
wenzelm@26782
   387
wenzelm@26782
   388
  \medskip The \railtterm{cong} modifiers add or delete Simplifier
wenzelm@26782
   389
  congruence rules (see also \cite{isabelle-ref}), the default is to
wenzelm@26782
   390
  add.
wenzelm@26782
   391
wenzelm@26782
   392
  \medskip The \railtterm{split} modifiers add or delete rules for the
wenzelm@26782
   393
  Splitter (see also \cite{isabelle-ref}), the default is to add.
wenzelm@26782
   394
  This works only if the Simplifier method has been properly setup to
wenzelm@26782
   395
  include the Splitter (all major object logics such HOL, HOLCF, FOL,
wenzelm@26782
   396
  ZF do this already).
wenzelm@26782
   397
wenzelm@28760
   398
  \item @{method simp_all} is similar to @{method simp}, but acts on
wenzelm@26782
   399
  all goals (backwards from the last to the first one).
wenzelm@26782
   400
wenzelm@28760
   401
  \end{description}
wenzelm@26782
   402
wenzelm@26782
   403
  By default the Simplifier methods take local assumptions fully into
wenzelm@26782
   404
  account, using equational assumptions in the subsequent
wenzelm@26782
   405
  normalization process, or simplifying assumptions themselves (cf.\
wenzelm@26782
   406
  @{ML asm_full_simp_tac} in \cite[\S10]{isabelle-ref}).  In
wenzelm@26782
   407
  structured proofs this is usually quite well behaved in practice:
wenzelm@26782
   408
  just the local premises of the actual goal are involved, additional
wenzelm@26782
   409
  facts may be inserted via explicit forward-chaining (via @{command
wenzelm@26782
   410
  "then"}, @{command "from"}, @{command "using"} etc.).  The full
wenzelm@26782
   411
  context of premises is only included if the ``@{text "!"}'' (bang)
wenzelm@26782
   412
  argument is given, which should be used with some care, though.
wenzelm@26782
   413
wenzelm@26782
   414
  Additional Simplifier options may be specified to tune the behavior
wenzelm@26782
   415
  further (mostly for unstructured scripts with many accidental local
wenzelm@26782
   416
  facts): ``@{text "(no_asm)"}'' means assumptions are ignored
wenzelm@26782
   417
  completely (cf.\ @{ML simp_tac}), ``@{text "(no_asm_simp)"}'' means
wenzelm@26782
   418
  assumptions are used in the simplification of the conclusion but are
wenzelm@26782
   419
  not themselves simplified (cf.\ @{ML asm_simp_tac}), and ``@{text
wenzelm@26782
   420
  "(no_asm_use)"}'' means assumptions are simplified but are not used
wenzelm@26782
   421
  in the simplification of each other or the conclusion (cf.\ @{ML
wenzelm@26782
   422
  full_simp_tac}).  For compatibility reasons, there is also an option
wenzelm@26782
   423
  ``@{text "(asm_lr)"}'', which means that an assumption is only used
wenzelm@26782
   424
  for simplifying assumptions which are to the right of it (cf.\ @{ML
wenzelm@26782
   425
  asm_lr_simp_tac}).
wenzelm@26782
   426
wenzelm@27092
   427
  The configuration option @{text "depth_limit"} limits the number of
wenzelm@26782
   428
  recursive invocations of the simplifier during conditional
wenzelm@26782
   429
  rewriting.
wenzelm@26782
   430
wenzelm@26782
   431
  \medskip The Splitter package is usually configured to work as part
wenzelm@26782
   432
  of the Simplifier.  The effect of repeatedly applying @{ML
wenzelm@26782
   433
  split_tac} can be simulated by ``@{text "(simp only: split:
wenzelm@26782
   434
  a\<^sub>1 \<dots> a\<^sub>n)"}''.  There is also a separate @{text split}
wenzelm@26782
   435
  method available for single-step case splitting.
wenzelm@26782
   436
*}
wenzelm@26782
   437
wenzelm@26782
   438
wenzelm@27040
   439
subsection {* Declaring rules *}
wenzelm@26782
   440
wenzelm@26782
   441
text {*
wenzelm@26782
   442
  \begin{matharray}{rcl}
wenzelm@28761
   443
    @{command_def "print_simpset"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\
wenzelm@28761
   444
    @{attribute_def simp} & : & @{text attribute} \\
wenzelm@28761
   445
    @{attribute_def cong} & : & @{text attribute} \\
wenzelm@28761
   446
    @{attribute_def split} & : & @{text attribute} \\
wenzelm@26782
   447
  \end{matharray}
wenzelm@26782
   448
wenzelm@26782
   449
  \begin{rail}
wenzelm@26782
   450
    ('simp' | 'cong' | 'split') (() | 'add' | 'del')
wenzelm@26782
   451
    ;
wenzelm@26782
   452
  \end{rail}
wenzelm@26782
   453
wenzelm@28760
   454
  \begin{description}
wenzelm@26782
   455
wenzelm@28760
   456
  \item @{command "print_simpset"} prints the collection of rules
wenzelm@26782
   457
  declared to the Simplifier, which is also known as ``simpset''
wenzelm@26782
   458
  internally \cite{isabelle-ref}.
wenzelm@26782
   459
wenzelm@28760
   460
  \item @{attribute simp} declares simplification rules.
wenzelm@26782
   461
wenzelm@28760
   462
  \item @{attribute cong} declares congruence rules.
wenzelm@26782
   463
wenzelm@28760
   464
  \item @{attribute split} declares case split rules.
wenzelm@26782
   465
wenzelm@28760
   466
  \end{description}
wenzelm@26782
   467
*}
wenzelm@26782
   468
wenzelm@26782
   469
wenzelm@27040
   470
subsection {* Simplification procedures *}
wenzelm@26782
   471
wenzelm@26782
   472
text {*
wenzelm@26782
   473
  \begin{matharray}{rcl}
wenzelm@28761
   474
    @{command_def "simproc_setup"} & : & @{text "local_theory \<rightarrow> local_theory"} \\
wenzelm@28761
   475
    simproc & : & @{text attribute} \\
wenzelm@26782
   476
  \end{matharray}
wenzelm@26782
   477
wenzelm@26782
   478
  \begin{rail}
wenzelm@26782
   479
    'simproc\_setup' name '(' (term + '|') ')' '=' text \\ ('identifier' (nameref+))?
wenzelm@26782
   480
    ;
wenzelm@26782
   481
wenzelm@26782
   482
    'simproc' (('add' ':')? | 'del' ':') (name+)
wenzelm@26782
   483
    ;
wenzelm@26782
   484
  \end{rail}
wenzelm@26782
   485
wenzelm@28760
   486
  \begin{description}
wenzelm@26782
   487
wenzelm@28760
   488
  \item @{command "simproc_setup"} defines a named simplification
wenzelm@26782
   489
  procedure that is invoked by the Simplifier whenever any of the
wenzelm@26782
   490
  given term patterns match the current redex.  The implementation,
wenzelm@26782
   491
  which is provided as ML source text, needs to be of type @{ML_type
wenzelm@26782
   492
  "morphism -> simpset -> cterm -> thm option"}, where the @{ML_type
wenzelm@26782
   493
  cterm} represents the current redex @{text r} and the result is
wenzelm@26782
   494
  supposed to be some proven rewrite rule @{text "r \<equiv> r'"} (or a
wenzelm@26782
   495
  generalized version), or @{ML NONE} to indicate failure.  The
wenzelm@26782
   496
  @{ML_type simpset} argument holds the full context of the current
wenzelm@26782
   497
  Simplifier invocation, including the actual Isar proof context.  The
wenzelm@26782
   498
  @{ML_type morphism} informs about the difference of the original
wenzelm@26782
   499
  compilation context wrt.\ the one of the actual application later
wenzelm@26782
   500
  on.  The optional @{keyword "identifier"} specifies theorems that
wenzelm@26782
   501
  represent the logical content of the abstract theory of this
wenzelm@26782
   502
  simproc.
wenzelm@26782
   503
wenzelm@26782
   504
  Morphisms and identifiers are only relevant for simprocs that are
wenzelm@26782
   505
  defined within a local target context, e.g.\ in a locale.
wenzelm@26782
   506
wenzelm@28760
   507
  \item @{text "simproc add: name"} and @{text "simproc del: name"}
wenzelm@26782
   508
  add or delete named simprocs to the current Simplifier context.  The
wenzelm@26782
   509
  default is to add a simproc.  Note that @{command "simproc_setup"}
wenzelm@26782
   510
  already adds the new simproc to the subsequent context.
wenzelm@26782
   511
wenzelm@28760
   512
  \end{description}
wenzelm@26782
   513
*}
wenzelm@26782
   514
wenzelm@26782
   515
wenzelm@27040
   516
subsection {* Forward simplification *}
wenzelm@26782
   517
wenzelm@26782
   518
text {*
wenzelm@26782
   519
  \begin{matharray}{rcl}
wenzelm@28761
   520
    @{attribute_def simplified} & : & @{text attribute} \\
wenzelm@26782
   521
  \end{matharray}
wenzelm@26782
   522
wenzelm@26782
   523
  \begin{rail}
wenzelm@26782
   524
    'simplified' opt? thmrefs?
wenzelm@26782
   525
    ;
wenzelm@26782
   526
wenzelm@26789
   527
    opt: '(' ('no\_asm' | 'no\_asm\_simp' | 'no\_asm\_use') ')'
wenzelm@26782
   528
    ;
wenzelm@26782
   529
  \end{rail}
wenzelm@26782
   530
wenzelm@28760
   531
  \begin{description}
wenzelm@26782
   532
  
wenzelm@28760
   533
  \item @{attribute simplified}~@{text "a\<^sub>1 \<dots> a\<^sub>n"} causes a theorem to
wenzelm@28760
   534
  be simplified, either by exactly the specified rules @{text "a\<^sub>1, \<dots>,
wenzelm@28760
   535
  a\<^sub>n"}, or the implicit Simplifier context if no arguments are given.
wenzelm@28760
   536
  The result is fully simplified by default, including assumptions and
wenzelm@28760
   537
  conclusion; the options @{text no_asm} etc.\ tune the Simplifier in
wenzelm@28760
   538
  the same way as the for the @{text simp} method.
wenzelm@26782
   539
wenzelm@26782
   540
  Note that forward simplification restricts the simplifier to its
wenzelm@26782
   541
  most basic operation of term rewriting; solver and looper tactics
wenzelm@26782
   542
  \cite{isabelle-ref} are \emph{not} involved here.  The @{text
wenzelm@26782
   543
  simplified} attribute should be only rarely required under normal
wenzelm@26782
   544
  circumstances.
wenzelm@26782
   545
wenzelm@28760
   546
  \end{description}
wenzelm@26782
   547
*}
wenzelm@26782
   548
wenzelm@26782
   549
wenzelm@27040
   550
section {* The Classical Reasoner \label{sec:classical} *}
wenzelm@26782
   551
wenzelm@27040
   552
subsection {* Basic methods *}
wenzelm@26782
   553
wenzelm@26782
   554
text {*
wenzelm@26782
   555
  \begin{matharray}{rcl}
wenzelm@28761
   556
    @{method_def rule} & : & @{text method} \\
wenzelm@28761
   557
    @{method_def contradiction} & : & @{text method} \\
wenzelm@28761
   558
    @{method_def intro} & : & @{text method} \\
wenzelm@28761
   559
    @{method_def elim} & : & @{text method} \\
wenzelm@26782
   560
  \end{matharray}
wenzelm@26782
   561
wenzelm@26782
   562
  \begin{rail}
wenzelm@26782
   563
    ('rule' | 'intro' | 'elim') thmrefs?
wenzelm@26782
   564
    ;
wenzelm@26782
   565
  \end{rail}
wenzelm@26782
   566
wenzelm@28760
   567
  \begin{description}
wenzelm@26782
   568
wenzelm@28760
   569
  \item @{method rule} as offered by the Classical Reasoner is a
wenzelm@26782
   570
  refinement over the primitive one (see \secref{sec:pure-meth-att}).
wenzelm@26782
   571
  Both versions essentially work the same, but the classical version
wenzelm@26782
   572
  observes the classical rule context in addition to that of
wenzelm@26782
   573
  Isabelle/Pure.
wenzelm@26782
   574
wenzelm@26782
   575
  Common object logics (HOL, ZF, etc.) declare a rich collection of
wenzelm@26782
   576
  classical rules (even if these would qualify as intuitionistic
wenzelm@26782
   577
  ones), but only few declarations to the rule context of
wenzelm@26782
   578
  Isabelle/Pure (\secref{sec:pure-meth-att}).
wenzelm@26782
   579
wenzelm@28760
   580
  \item @{method contradiction} solves some goal by contradiction,
wenzelm@26782
   581
  deriving any result from both @{text "\<not> A"} and @{text A}.  Chained
wenzelm@26782
   582
  facts, which are guaranteed to participate, may appear in either
wenzelm@26782
   583
  order.
wenzelm@26782
   584
wenzelm@28760
   585
  \item @{method intro} and @{method elim} repeatedly refine some goal
wenzelm@28760
   586
  by intro- or elim-resolution, after having inserted any chained
wenzelm@26901
   587
  facts.  Exactly the rules given as arguments are taken into account;
wenzelm@26901
   588
  this allows fine-tuned decomposition of a proof problem, in contrast
wenzelm@26901
   589
  to common automated tools.
wenzelm@26782
   590
wenzelm@28760
   591
  \end{description}
wenzelm@26782
   592
*}
wenzelm@26782
   593
wenzelm@26782
   594
wenzelm@27040
   595
subsection {* Automated methods *}
wenzelm@26782
   596
wenzelm@26782
   597
text {*
wenzelm@26782
   598
  \begin{matharray}{rcl}
wenzelm@28761
   599
    @{method_def blast} & : & @{text method} \\
wenzelm@28761
   600
    @{method_def fast} & : & @{text method} \\
wenzelm@28761
   601
    @{method_def slow} & : & @{text method} \\
wenzelm@28761
   602
    @{method_def best} & : & @{text method} \\
wenzelm@28761
   603
    @{method_def safe} & : & @{text method} \\
wenzelm@28761
   604
    @{method_def clarify} & : & @{text method} \\
wenzelm@26782
   605
  \end{matharray}
wenzelm@26782
   606
wenzelm@26782
   607
  \indexouternonterm{clamod}
wenzelm@26782
   608
  \begin{rail}
wenzelm@26782
   609
    'blast' ('!' ?) nat? (clamod *)
wenzelm@26782
   610
    ;
wenzelm@26782
   611
    ('fast' | 'slow' | 'best' | 'safe' | 'clarify') ('!' ?) (clamod *)
wenzelm@26782
   612
    ;
wenzelm@26782
   613
wenzelm@26782
   614
    clamod: (('intro' | 'elim' | 'dest') ('!' | () | '?') | 'del') ':' thmrefs
wenzelm@26782
   615
    ;
wenzelm@26782
   616
  \end{rail}
wenzelm@26782
   617
wenzelm@28760
   618
  \begin{description}
wenzelm@26782
   619
wenzelm@28760
   620
  \item @{method blast} refers to the classical tableau prover (see
wenzelm@26782
   621
  @{ML blast_tac} in \cite[\S11]{isabelle-ref}).  The optional
wenzelm@26782
   622
  argument specifies a user-supplied search bound (default 20).
wenzelm@26782
   623
wenzelm@28760
   624
  \item @{method fast}, @{method slow}, @{method best}, @{method
wenzelm@28760
   625
  safe}, and @{method clarify} refer to the generic classical
wenzelm@26782
   626
  reasoner.  See @{ML fast_tac}, @{ML slow_tac}, @{ML best_tac}, @{ML
wenzelm@26782
   627
  safe_tac}, and @{ML clarify_tac} in \cite[\S11]{isabelle-ref} for
wenzelm@26782
   628
  more information.
wenzelm@26782
   629
wenzelm@28760
   630
  \end{description}
wenzelm@26782
   631
wenzelm@26782
   632
  Any of the above methods support additional modifiers of the context
wenzelm@26782
   633
  of classical rules.  Their semantics is analogous to the attributes
wenzelm@26782
   634
  given before.  Facts provided by forward chaining are inserted into
wenzelm@26782
   635
  the goal before commencing proof search.  The ``@{text
wenzelm@26782
   636
  "!"}''~argument causes the full context of assumptions to be
wenzelm@26782
   637
  included as well.
wenzelm@26782
   638
*}
wenzelm@26782
   639
wenzelm@26782
   640
wenzelm@27040
   641
subsection {* Combined automated methods \label{sec:clasimp} *}
wenzelm@26782
   642
wenzelm@26782
   643
text {*
wenzelm@26782
   644
  \begin{matharray}{rcl}
wenzelm@28761
   645
    @{method_def auto} & : & @{text method} \\
wenzelm@28761
   646
    @{method_def force} & : & @{text method} \\
wenzelm@28761
   647
    @{method_def clarsimp} & : & @{text method} \\
wenzelm@28761
   648
    @{method_def fastsimp} & : & @{text method} \\
wenzelm@28761
   649
    @{method_def slowsimp} & : & @{text method} \\
wenzelm@28761
   650
    @{method_def bestsimp} & : & @{text method} \\
wenzelm@26782
   651
  \end{matharray}
wenzelm@26782
   652
wenzelm@26782
   653
  \indexouternonterm{clasimpmod}
wenzelm@26782
   654
  \begin{rail}
wenzelm@26782
   655
    'auto' '!'? (nat nat)? (clasimpmod *)
wenzelm@26782
   656
    ;
wenzelm@26782
   657
    ('force' | 'clarsimp' | 'fastsimp' | 'slowsimp' | 'bestsimp') '!'? (clasimpmod *)
wenzelm@26782
   658
    ;
wenzelm@26782
   659
wenzelm@26782
   660
    clasimpmod: ('simp' (() | 'add' | 'del' | 'only') |
wenzelm@26782
   661
      ('cong' | 'split') (() | 'add' | 'del') |
wenzelm@26782
   662
      'iff' (((() | 'add') '?'?) | 'del') |
wenzelm@26782
   663
      (('intro' | 'elim' | 'dest') ('!' | () | '?') | 'del')) ':' thmrefs
wenzelm@26782
   664
  \end{rail}
wenzelm@26782
   665
wenzelm@28760
   666
  \begin{description}
wenzelm@26782
   667
wenzelm@28760
   668
  \item @{method auto}, @{method force}, @{method clarsimp}, @{method
wenzelm@28760
   669
  fastsimp}, @{method slowsimp}, and @{method bestsimp} provide access
wenzelm@28760
   670
  to Isabelle's combined simplification and classical reasoning
wenzelm@26782
   671
  tactics.  These correspond to @{ML auto_tac}, @{ML force_tac}, @{ML
wenzelm@26782
   672
  clarsimp_tac}, and Classical Reasoner tactics with the Simplifier
wenzelm@26782
   673
  added as wrapper, see \cite[\S11]{isabelle-ref} for more
wenzelm@26782
   674
  information.  The modifier arguments correspond to those given in
wenzelm@26782
   675
  \secref{sec:simplifier} and \secref{sec:classical}.  Just note that
wenzelm@26782
   676
  the ones related to the Simplifier are prefixed by \railtterm{simp}
wenzelm@26782
   677
  here.
wenzelm@26782
   678
wenzelm@26782
   679
  Facts provided by forward chaining are inserted into the goal before
wenzelm@26782
   680
  doing the search.  The ``@{text "!"}'' argument causes the full
wenzelm@26782
   681
  context of assumptions to be included as well.
wenzelm@26782
   682
wenzelm@28760
   683
  \end{description}
wenzelm@26782
   684
*}
wenzelm@26782
   685
wenzelm@26782
   686
wenzelm@27040
   687
subsection {* Declaring rules *}
wenzelm@26782
   688
wenzelm@26782
   689
text {*
wenzelm@26782
   690
  \begin{matharray}{rcl}
wenzelm@28761
   691
    @{command_def "print_claset"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\
wenzelm@28761
   692
    @{attribute_def intro} & : & @{text attribute} \\
wenzelm@28761
   693
    @{attribute_def elim} & : & @{text attribute} \\
wenzelm@28761
   694
    @{attribute_def dest} & : & @{text attribute} \\
wenzelm@28761
   695
    @{attribute_def rule} & : & @{text attribute} \\
wenzelm@28761
   696
    @{attribute_def iff} & : & @{text attribute} \\
wenzelm@26782
   697
  \end{matharray}
wenzelm@26782
   698
wenzelm@26782
   699
  \begin{rail}
wenzelm@26782
   700
    ('intro' | 'elim' | 'dest') ('!' | () | '?') nat?
wenzelm@26782
   701
    ;
wenzelm@26782
   702
    'rule' 'del'
wenzelm@26782
   703
    ;
wenzelm@26782
   704
    'iff' (((() | 'add') '?'?) | 'del')
wenzelm@26782
   705
    ;
wenzelm@26782
   706
  \end{rail}
wenzelm@26782
   707
wenzelm@28760
   708
  \begin{description}
wenzelm@26782
   709
wenzelm@28760
   710
  \item @{command "print_claset"} prints the collection of rules
wenzelm@26782
   711
  declared to the Classical Reasoner, which is also known as
wenzelm@26782
   712
  ``claset'' internally \cite{isabelle-ref}.
wenzelm@26782
   713
  
wenzelm@28760
   714
  \item @{attribute intro}, @{attribute elim}, and @{attribute dest}
wenzelm@26782
   715
  declare introduction, elimination, and destruction rules,
wenzelm@26782
   716
  respectively.  By default, rules are considered as \emph{unsafe}
wenzelm@26782
   717
  (i.e.\ not applied blindly without backtracking), while ``@{text
wenzelm@26782
   718
  "!"}'' classifies as \emph{safe}.  Rule declarations marked by
wenzelm@26782
   719
  ``@{text "?"}'' coincide with those of Isabelle/Pure, cf.\
wenzelm@26782
   720
  \secref{sec:pure-meth-att} (i.e.\ are only applied in single steps
wenzelm@26782
   721
  of the @{method rule} method).  The optional natural number
wenzelm@26782
   722
  specifies an explicit weight argument, which is ignored by automated
wenzelm@26782
   723
  tools, but determines the search order of single rule steps.
wenzelm@26782
   724
wenzelm@28760
   725
  \item @{attribute rule}~@{text del} deletes introduction,
wenzelm@26782
   726
  elimination, or destruction rules from the context.
wenzelm@26782
   727
wenzelm@28760
   728
  \item @{attribute iff} declares logical equivalences to the
wenzelm@26782
   729
  Simplifier and the Classical reasoner at the same time.
wenzelm@26782
   730
  Non-conditional rules result in a ``safe'' introduction and
wenzelm@26782
   731
  elimination pair; conditional ones are considered ``unsafe''.  Rules
wenzelm@26782
   732
  with negative conclusion are automatically inverted (using @{text
wenzelm@26789
   733
  "\<not>"}-elimination internally).
wenzelm@26782
   734
wenzelm@26782
   735
  The ``@{text "?"}'' version of @{attribute iff} declares rules to
wenzelm@26782
   736
  the Isabelle/Pure context only, and omits the Simplifier
wenzelm@26782
   737
  declaration.
wenzelm@26782
   738
wenzelm@28760
   739
  \end{description}
wenzelm@26782
   740
*}
wenzelm@26782
   741
wenzelm@26782
   742
wenzelm@27040
   743
subsection {* Classical operations *}
wenzelm@26782
   744
wenzelm@26782
   745
text {*
wenzelm@26782
   746
  \begin{matharray}{rcl}
wenzelm@28761
   747
    @{attribute_def swapped} & : & @{text attribute} \\
wenzelm@26782
   748
  \end{matharray}
wenzelm@26782
   749
wenzelm@28760
   750
  \begin{description}
wenzelm@26782
   751
wenzelm@28760
   752
  \item @{attribute swapped} turns an introduction rule into an
wenzelm@26782
   753
  elimination, by resolving with the classical swap principle @{text
wenzelm@26782
   754
  "(\<not> B \<Longrightarrow> A) \<Longrightarrow> (\<not> A \<Longrightarrow> B)"}.
wenzelm@26782
   755
wenzelm@28760
   756
  \end{description}
wenzelm@26782
   757
*}
wenzelm@26782
   758
wenzelm@26782
   759
wenzelm@27044
   760
section {* Object-logic setup \label{sec:object-logic} *}
wenzelm@26790
   761
wenzelm@26790
   762
text {*
wenzelm@26790
   763
  \begin{matharray}{rcl}
wenzelm@28761
   764
    @{command_def "judgment"} & : & @{text "theory \<rightarrow> theory"} \\
wenzelm@28761
   765
    @{method_def atomize} & : & @{text method} \\
wenzelm@28761
   766
    @{attribute_def atomize} & : & @{text attribute} \\
wenzelm@28761
   767
    @{attribute_def rule_format} & : & @{text attribute} \\
wenzelm@28761
   768
    @{attribute_def rulify} & : & @{text attribute} \\
wenzelm@26790
   769
  \end{matharray}
wenzelm@26790
   770
wenzelm@26790
   771
  The very starting point for any Isabelle object-logic is a ``truth
wenzelm@26790
   772
  judgment'' that links object-level statements to the meta-logic
wenzelm@26790
   773
  (with its minimal language of @{text prop} that covers universal
wenzelm@26790
   774
  quantification @{text "\<And>"} and implication @{text "\<Longrightarrow>"}).
wenzelm@26790
   775
wenzelm@26790
   776
  Common object-logics are sufficiently expressive to internalize rule
wenzelm@26790
   777
  statements over @{text "\<And>"} and @{text "\<Longrightarrow>"} within their own
wenzelm@26790
   778
  language.  This is useful in certain situations where a rule needs
wenzelm@26790
   779
  to be viewed as an atomic statement from the meta-level perspective,
wenzelm@26790
   780
  e.g.\ @{text "\<And>x. x \<in> A \<Longrightarrow> P x"} versus @{text "\<forall>x \<in> A. P x"}.
wenzelm@26790
   781
wenzelm@26790
   782
  From the following language elements, only the @{method atomize}
wenzelm@26790
   783
  method and @{attribute rule_format} attribute are occasionally
wenzelm@26790
   784
  required by end-users, the rest is for those who need to setup their
wenzelm@26790
   785
  own object-logic.  In the latter case existing formulations of
wenzelm@26790
   786
  Isabelle/FOL or Isabelle/HOL may be taken as realistic examples.
wenzelm@26790
   787
wenzelm@26790
   788
  Generic tools may refer to the information provided by object-logic
wenzelm@26790
   789
  declarations internally.
wenzelm@26790
   790
wenzelm@26790
   791
  \begin{rail}
wenzelm@26790
   792
    'judgment' constdecl
wenzelm@26790
   793
    ;
wenzelm@26790
   794
    'atomize' ('(' 'full' ')')?
wenzelm@26790
   795
    ;
wenzelm@26790
   796
    'rule\_format' ('(' 'noasm' ')')?
wenzelm@26790
   797
    ;
wenzelm@26790
   798
  \end{rail}
wenzelm@26790
   799
wenzelm@28760
   800
  \begin{description}
wenzelm@26790
   801
  
wenzelm@28760
   802
  \item @{command "judgment"}~@{text "c :: \<sigma> (mx)"} declares constant
wenzelm@28760
   803
  @{text c} as the truth judgment of the current object-logic.  Its
wenzelm@28760
   804
  type @{text \<sigma>} should specify a coercion of the category of
wenzelm@28760
   805
  object-level propositions to @{text prop} of the Pure meta-logic;
wenzelm@28760
   806
  the mixfix annotation @{text "(mx)"} would typically just link the
wenzelm@28760
   807
  object language (internally of syntactic category @{text logic})
wenzelm@28760
   808
  with that of @{text prop}.  Only one @{command "judgment"}
wenzelm@28760
   809
  declaration may be given in any theory development.
wenzelm@26790
   810
  
wenzelm@28760
   811
  \item @{method atomize} (as a method) rewrites any non-atomic
wenzelm@26790
   812
  premises of a sub-goal, using the meta-level equations declared via
wenzelm@26790
   813
  @{attribute atomize} (as an attribute) beforehand.  As a result,
wenzelm@26790
   814
  heavily nested goals become amenable to fundamental operations such
wenzelm@26790
   815
  as resolution (cf.\ the @{method rule} method).  Giving the ``@{text
wenzelm@26790
   816
  "(full)"}'' option here means to turn the whole subgoal into an
wenzelm@26790
   817
  object-statement (if possible), including the outermost parameters
wenzelm@26790
   818
  and assumptions as well.
wenzelm@26790
   819
wenzelm@26790
   820
  A typical collection of @{attribute atomize} rules for a particular
wenzelm@26790
   821
  object-logic would provide an internalization for each of the
wenzelm@26790
   822
  connectives of @{text "\<And>"}, @{text "\<Longrightarrow>"}, and @{text "\<equiv>"}.
wenzelm@26790
   823
  Meta-level conjunction should be covered as well (this is
wenzelm@26790
   824
  particularly important for locales, see \secref{sec:locale}).
wenzelm@26790
   825
wenzelm@28760
   826
  \item @{attribute rule_format} rewrites a theorem by the equalities
wenzelm@28760
   827
  declared as @{attribute rulify} rules in the current object-logic.
wenzelm@28760
   828
  By default, the result is fully normalized, including assumptions
wenzelm@28760
   829
  and conclusions at any depth.  The @{text "(no_asm)"} option
wenzelm@28760
   830
  restricts the transformation to the conclusion of a rule.
wenzelm@26790
   831
wenzelm@26790
   832
  In common object-logics (HOL, FOL, ZF), the effect of @{attribute
wenzelm@26790
   833
  rule_format} is to replace (bounded) universal quantification
wenzelm@26790
   834
  (@{text "\<forall>"}) and implication (@{text "\<longrightarrow>"}) by the corresponding
wenzelm@26790
   835
  rule statements over @{text "\<And>"} and @{text "\<Longrightarrow>"}.
wenzelm@26790
   836
wenzelm@28760
   837
  \end{description}
wenzelm@26790
   838
*}
wenzelm@26790
   839
wenzelm@26782
   840
end