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