doc-src/IsarRef/Thy/Misc.thy
author Walther Neuper <neuper@ist.tugraz.at>
Thu, 12 Aug 2010 15:03:34 +0200
branchisac-from-Isabelle2009-2
changeset 37913 20e3616b2d9c
parent 33515 d066e8369a33
child 40275 a194f39cfcb4
permissions -rw-r--r--
prepare reactivation of isac-update-Isa09-2
     1 theory Misc
     2 imports Main
     3 begin
     4 
     5 chapter {* Other commands *}
     6 
     7 section {* Inspecting the context *}
     8 
     9 text {*
    10   \begin{matharray}{rcl}
    11     @{command_def "print_commands"}@{text "\<^sup>*"} & : & @{text "any \<rightarrow>"} \\
    12     @{command_def "print_theory"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\
    13     @{command_def "print_methods"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\
    14     @{command_def "print_attributes"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\
    15     @{command_def "print_theorems"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\
    16     @{command_def "find_theorems"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\
    17     @{command_def "find_consts"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\
    18     @{command_def "thm_deps"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\
    19     @{command_def "print_facts"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\
    20     @{command_def "print_binds"}@{text "\<^sup>*"} & : & @{text "context \<rightarrow>"} \\
    21   \end{matharray}
    22 
    23   \begin{rail}
    24     ('print\_theory' | 'print\_theorems') ('!'?)
    25     ;
    26 
    27     'find\_theorems' (('(' (nat)? ('with\_dups')? ')')?) (thmcriterion *)
    28     ;
    29     thmcriterion: ('-'?) ('name' ':' nameref | 'intro' | 'elim' | 'dest' |
    30       'solves' | 'simp' ':' term | term)
    31     ;
    32     'find\_consts' (constcriterion *)
    33     ;
    34     constcriterion: ('-'?) ('name' ':' nameref | 'strict' ':' type | type)
    35     ;
    36     'thm\_deps' thmrefs
    37     ;
    38   \end{rail}
    39 
    40   These commands print certain parts of the theory and proof context.
    41   Note that there are some further ones available, such as for the set
    42   of rules declared for simplifications.
    43 
    44   \begin{description}
    45   
    46   \item @{command "print_commands"} prints Isabelle's outer theory
    47   syntax, including keywords and command.
    48   
    49   \item @{command "print_theory"} prints the main logical content of
    50   the theory context; the ``@{text "!"}'' option indicates extra
    51   verbosity.
    52 
    53   \item @{command "print_methods"} prints all proof methods
    54   available in the current theory context.
    55   
    56   \item @{command "print_attributes"} prints all attributes
    57   available in the current theory context.
    58   
    59   \item @{command "print_theorems"} prints theorems resulting from the
    60   last command; the ``@{text "!"}'' option indicates extra verbosity.
    61   
    62   \item @{command "find_theorems"}~@{text criteria} retrieves facts
    63   from the theory or proof context matching all of given search
    64   criteria.  The criterion @{text "name: p"} selects all theorems
    65   whose fully qualified name matches pattern @{text p}, which may
    66   contain ``@{text "*"}'' wildcards.  The criteria @{text intro},
    67   @{text elim}, and @{text dest} select theorems that match the
    68   current goal as introduction, elimination or destruction rules,
    69   respectively.  The criterion @{text "solves"} returns all rules
    70   that would directly solve the current goal.  The criterion
    71   @{text "simp: t"} selects all rewrite rules whose left-hand side
    72   matches the given term.  The criterion term @{text t} selects all
    73   theorems that contain the pattern @{text t} -- as usual, patterns
    74   may contain occurrences of the dummy ``@{text _}'', schematic
    75   variables, and type constraints.
    76   
    77   Criteria can be preceded by ``@{text "-"}'' to select theorems that
    78   do \emph{not} match. Note that giving the empty list of criteria
    79   yields \emph{all} currently known facts.  An optional limit for the
    80   number of printed facts may be given; the default is 40.  By
    81   default, duplicates are removed from the search result. Use
    82   @{text with_dups} to display duplicates.
    83 
    84   \item @{command "find_consts"}~@{text criteria} prints all constants
    85   whose type meets all of the given criteria. The criterion @{text
    86   "strict: ty"} is met by any type that matches the type pattern
    87   @{text ty}.  Patterns may contain both the dummy type ``@{text _}''
    88   and sort constraints. The criterion @{text ty} is similar, but it
    89   also matches against subtypes. The criterion @{text "name: p"} and
    90   the prefix ``@{text "-"}'' function as described for @{command
    91   "find_theorems"}.
    92 
    93   \item @{command "thm_deps"}~@{text "a\<^sub>1 \<dots> a\<^sub>n"}
    94   visualizes dependencies of facts, using Isabelle's graph browser
    95   tool (see also \cite{isabelle-sys}).
    96   
    97   \item @{command "print_facts"} prints all local facts of the
    98   current context, both named and unnamed ones.
    99   
   100   \item @{command "print_binds"} prints all term abbreviations
   101   present in the context.
   102 
   103   \end{description}
   104 *}
   105 
   106 
   107 section {* History commands \label{sec:history} *}
   108 
   109 text {*
   110   \begin{matharray}{rcl}
   111     @{command_def "undo"}^{{ * }{ * }} & : & @{text "any \<rightarrow> any"} \\
   112     @{command_def "linear_undo"}^{{ * }{ * }} & : & @{text "any \<rightarrow> any"} \\
   113     @{command_def "kill"}^{{ * }{ * }} & : & @{text "any \<rightarrow> any"} \\
   114   \end{matharray}
   115 
   116   The Isabelle/Isar top-level maintains a two-stage history, for
   117   theory and proof state transformation.  Basically, any command can
   118   be undone using @{command "undo"}, excluding mere diagnostic
   119   elements.  Note that a theorem statement with a \emph{finished}
   120   proof is treated as a single unit by @{command "undo"}.  In
   121   contrast, the variant @{command "linear_undo"} admits to step back
   122   into the middle of a proof.  The @{command "kill"} command aborts
   123   the current history node altogether, discontinuing a proof or even
   124   the whole theory.  This operation is \emph{not} undo-able.
   125 
   126   \begin{warn}
   127     History commands should never be used with user interfaces such as
   128     Proof~General \cite{proofgeneral,Aspinall:TACAS:2000}, which takes
   129     care of stepping forth and back itself.  Interfering by manual
   130     @{command "undo"}, @{command "linear_undo"}, or even @{command
   131     "kill"} commands would quickly result in utter confusion.
   132   \end{warn}
   133 *}
   134 
   135 
   136 section {* System commands *}
   137 
   138 text {*
   139   \begin{matharray}{rcl}
   140     @{command_def "cd"}@{text "\<^sup>*"} & : & @{text "any \<rightarrow>"} \\
   141     @{command_def "pwd"}@{text "\<^sup>*"} & : & @{text "any \<rightarrow>"} \\
   142     @{command_def "use_thy"}@{text "\<^sup>*"} & : & @{text "any \<rightarrow>"} \\
   143   \end{matharray}
   144 
   145   \begin{rail}
   146     ('cd' | 'use\_thy' | 'update\_thy') name
   147     ;
   148   \end{rail}
   149 
   150   \begin{description}
   151 
   152   \item @{command "cd"}~@{text path} changes the current directory
   153   of the Isabelle process.
   154 
   155   \item @{command "pwd"} prints the current working directory.
   156 
   157   \item @{command "use_thy"}~@{text A} preload theory @{text A}.
   158   These system commands are scarcely used when working interactively,
   159   since loading of theories is done automatically as required.
   160 
   161   \end{description}
   162 *}
   163 
   164 end