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