src/Doc/Isar_Ref/Proof_Script.thy
changeset 61439 2bf52eec4e8a
parent 60631 441fdbfbb2d3
child 61458 987533262fc2
equal deleted inserted replaced
61438:151f894984d8 61439:2bf52eec4e8a
    41     @@{command prefer} @{syntax nat}
    41     @@{command prefer} @{syntax nat}
    42   \<close>}
    42   \<close>}
    43 
    43 
    44   \begin{description}
    44   \begin{description}
    45 
    45 
    46   \item @{command "supply"} supports fact definitions during goal
    46   \<^descr> @{command "supply"} supports fact definitions during goal
    47   refinement: it is similar to @{command "note"}, but it operates in
    47   refinement: it is similar to @{command "note"}, but it operates in
    48   backwards mode and does not have any impact on chained facts.
    48   backwards mode and does not have any impact on chained facts.
    49 
    49 
    50   \item @{command "apply"}~@{text m} applies proof method @{text m} in
    50   \<^descr> @{command "apply"}~@{text m} applies proof method @{text m} in
    51   initial position, but unlike @{command "proof"} it retains ``@{text
    51   initial position, but unlike @{command "proof"} it retains ``@{text
    52   "proof(prove)"}'' mode.  Thus consecutive method applications may be
    52   "proof(prove)"}'' mode.  Thus consecutive method applications may be
    53   given just as in tactic scripts.
    53   given just as in tactic scripts.
    54 
    54 
    55   Facts are passed to @{text m} as indicated by the goal's
    55   Facts are passed to @{text m} as indicated by the goal's
    56   forward-chain mode, and are \emph{consumed} afterwards.  Thus any
    56   forward-chain mode, and are \emph{consumed} afterwards.  Thus any
    57   further @{command "apply"} command would always work in a purely
    57   further @{command "apply"} command would always work in a purely
    58   backward manner.
    58   backward manner.
    59 
    59 
    60   \item @{command "apply_end"}~@{text "m"} applies proof method @{text
    60   \<^descr> @{command "apply_end"}~@{text "m"} applies proof method @{text
    61   m} as if in terminal position.  Basically, this simulates a
    61   m} as if in terminal position.  Basically, this simulates a
    62   multi-step tactic script for @{command "qed"}, but may be given
    62   multi-step tactic script for @{command "qed"}, but may be given
    63   anywhere within the proof body.
    63   anywhere within the proof body.
    64 
    64 
    65   No facts are passed to @{text m} here.  Furthermore, the static
    65   No facts are passed to @{text m} here.  Furthermore, the static
    66   context is that of the enclosing goal (as for actual @{command
    66   context is that of the enclosing goal (as for actual @{command
    67   "qed"}).  Thus the proof method may not refer to any assumptions
    67   "qed"}).  Thus the proof method may not refer to any assumptions
    68   introduced in the current body, for example.
    68   introduced in the current body, for example.
    69 
    69 
    70   \item @{command "done"} completes a proof script, provided that the
    70   \<^descr> @{command "done"} completes a proof script, provided that the
    71   current goal state is solved completely.  Note that actual
    71   current goal state is solved completely.  Note that actual
    72   structured proof commands (e.g.\ ``@{command "."}'' or @{command
    72   structured proof commands (e.g.\ ``@{command "."}'' or @{command
    73   "sorry"}) may be used to conclude proof scripts as well.
    73   "sorry"}) may be used to conclude proof scripts as well.
    74 
    74 
    75   \item @{command "defer"}~@{text n} and @{command "prefer"}~@{text n}
    75   \<^descr> @{command "defer"}~@{text n} and @{command "prefer"}~@{text n}
    76   shuffle the list of pending goals: @{command "defer"} puts off
    76   shuffle the list of pending goals: @{command "defer"} puts off
    77   sub-goal @{text n} to the end of the list (@{text "n = 1"} by
    77   sub-goal @{text n} to the end of the list (@{text "n = 1"} by
    78   default), while @{command "prefer"} brings sub-goal @{text n} to the
    78   default), while @{command "prefer"} brings sub-goal @{text n} to the
    79   front.
    79   front.
    80 
    80 
    81   \item @{command "back"} does back-tracking over the result sequence
    81   \<^descr> @{command "back"} does back-tracking over the result sequence
    82   of the latest proof command.  Any proof command may return multiple
    82   of the latest proof command.  Any proof command may return multiple
    83   results, and this command explores the possibilities step-by-step.
    83   results, and this command explores the possibilities step-by-step.
    84   It is mainly useful for experimentation and interactive exploration,
    84   It is mainly useful for experimentation and interactive exploration,
    85   and should be avoided in finished proofs.
    85   and should be avoided in finished proofs.
    86 
    86 
   103     params: @'for' '\<dots>'? (('_' | @{syntax name})+)
   103     params: @'for' '\<dots>'? (('_' | @{syntax name})+)
   104   \<close>}
   104   \<close>}
   105 
   105 
   106   \begin{description}
   106   \begin{description}
   107 
   107 
   108   \item @{command "subgoal"} allows to impose some structure on backward
   108   \<^descr> @{command "subgoal"} allows to impose some structure on backward
   109   refinements, to avoid proof scripts degenerating into long of @{command
   109   refinements, to avoid proof scripts degenerating into long of @{command
   110   apply} sequences.
   110   apply} sequences.
   111 
   111 
   112   The current goal state, which is essentially a hidden part of the Isar/VM
   112   The current goal state, which is essentially a hidden part of the Isar/VM
   113   configurtation, is turned into a proof context and remaining conclusion.
   113   configurtation, is turned into a proof context and remaining conclusion.
   245     (@@{method tactic} | @@{method raw_tactic}) @{syntax text}
   245     (@@{method tactic} | @@{method raw_tactic}) @{syntax text}
   246   \<close>}
   246   \<close>}
   247 
   247 
   248 \begin{description}
   248 \begin{description}
   249 
   249 
   250   \item @{method rule_tac} etc. do resolution of rules with explicit
   250   \<^descr> @{method rule_tac} etc. do resolution of rules with explicit
   251   instantiation.  This works the same way as the ML tactics @{ML
   251   instantiation.  This works the same way as the ML tactics @{ML
   252   Rule_Insts.res_inst_tac} etc.\ (see @{cite "isabelle-implementation"}).
   252   Rule_Insts.res_inst_tac} etc.\ (see @{cite "isabelle-implementation"}).
   253 
   253 
   254   Multiple rules may be only given if there is no instantiation; then
   254   Multiple rules may be only given if there is no instantiation; then
   255   @{method rule_tac} is the same as @{ML resolve_tac} in ML (see
   255   @{method rule_tac} is the same as @{ML resolve_tac} in ML (see
   256   @{cite "isabelle-implementation"}).
   256   @{cite "isabelle-implementation"}).
   257 
   257 
   258   \item @{method cut_tac} inserts facts into the proof state as
   258   \<^descr> @{method cut_tac} inserts facts into the proof state as
   259   assumption of a subgoal; instantiations may be given as well.  Note
   259   assumption of a subgoal; instantiations may be given as well.  Note
   260   that the scope of schematic variables is spread over the main goal
   260   that the scope of schematic variables is spread over the main goal
   261   statement and rule premises are turned into new subgoals.  This is
   261   statement and rule premises are turned into new subgoals.  This is
   262   in contrast to the regular method @{method insert} which inserts
   262   in contrast to the regular method @{method insert} which inserts
   263   closed rule statements.
   263   closed rule statements.
   264 
   264 
   265   \item @{method thin_tac}~@{text \<phi>} deletes the specified premise
   265   \<^descr> @{method thin_tac}~@{text \<phi>} deletes the specified premise
   266   from a subgoal.  Note that @{text \<phi>} may contain schematic
   266   from a subgoal.  Note that @{text \<phi>} may contain schematic
   267   variables, to abbreviate the intended proposition; the first
   267   variables, to abbreviate the intended proposition; the first
   268   matching subgoal premise will be deleted.  Removing useless premises
   268   matching subgoal premise will be deleted.  Removing useless premises
   269   from a subgoal increases its readability and can make search tactics
   269   from a subgoal increases its readability and can make search tactics
   270   run faster.
   270   run faster.
   271 
   271 
   272   \item @{method subgoal_tac}~@{text "\<phi>\<^sub>1 \<dots> \<phi>\<^sub>n"} adds the propositions
   272   \<^descr> @{method subgoal_tac}~@{text "\<phi>\<^sub>1 \<dots> \<phi>\<^sub>n"} adds the propositions
   273   @{text "\<phi>\<^sub>1 \<dots> \<phi>\<^sub>n"} as local premises to a subgoal, and poses the same
   273   @{text "\<phi>\<^sub>1 \<dots> \<phi>\<^sub>n"} as local premises to a subgoal, and poses the same
   274   as new subgoals (in the original context).
   274   as new subgoals (in the original context).
   275 
   275 
   276   \item @{method rename_tac}~@{text "x\<^sub>1 \<dots> x\<^sub>n"} renames parameters of a
   276   \<^descr> @{method rename_tac}~@{text "x\<^sub>1 \<dots> x\<^sub>n"} renames parameters of a
   277   goal according to the list @{text "x\<^sub>1, \<dots>, x\<^sub>n"}, which refers to the
   277   goal according to the list @{text "x\<^sub>1, \<dots>, x\<^sub>n"}, which refers to the
   278   \emph{suffix} of variables.
   278   \emph{suffix} of variables.
   279 
   279 
   280   \item @{method rotate_tac}~@{text n} rotates the premises of a
   280   \<^descr> @{method rotate_tac}~@{text n} rotates the premises of a
   281   subgoal by @{text n} positions: from right to left if @{text n} is
   281   subgoal by @{text n} positions: from right to left if @{text n} is
   282   positive, and from left to right if @{text n} is negative; the
   282   positive, and from left to right if @{text n} is negative; the
   283   default value is 1.
   283   default value is 1.
   284 
   284 
   285   \item @{method tactic}~@{text "text"} produces a proof method from
   285   \<^descr> @{method tactic}~@{text "text"} produces a proof method from
   286   any ML text of type @{ML_type tactic}.  Apart from the usual ML
   286   any ML text of type @{ML_type tactic}.  Apart from the usual ML
   287   environment and the current proof context, the ML code may refer to
   287   environment and the current proof context, the ML code may refer to
   288   the locally bound values @{ML_text facts}, which indicates any
   288   the locally bound values @{ML_text facts}, which indicates any
   289   current facts used for forward-chaining.
   289   current facts used for forward-chaining.
   290 
   290 
   291   \item @{method raw_tactic} is similar to @{method tactic}, but
   291   \<^descr> @{method raw_tactic} is similar to @{method tactic}, but
   292   presents the goal state in its raw internal form, where simultaneous
   292   presents the goal state in its raw internal form, where simultaneous
   293   subgoals appear as conjunction of the logical framework instead of
   293   subgoals appear as conjunction of the logical framework instead of
   294   the usual split into several subgoals.  While feature this is useful
   294   the usual split into several subgoals.  While feature this is useful
   295   for debugging of complex method definitions, it should not never
   295   for debugging of complex method definitions, it should not never
   296   appear in production theories.
   296   appear in production theories.