doc-src/Ref/goals.tex
changeset 5391 8b22b93dba2c
parent 5371 e27558a68b8d
child 6170 9a59cf8ae9b5
equal deleted inserted replaced
5390:0c9e6d860485 5391:8b22b93dba2c
    22 The subgoal module always contains some proof state.  At the start of the
    22 The subgoal module always contains some proof state.  At the start of the
    23 Isabelle session, this state consists of a dummy formula.
    23 Isabelle session, this state consists of a dummy formula.
    24 
    24 
    25 
    25 
    26 \section{Basic commands}
    26 \section{Basic commands}
    27 Most proofs begin with \texttt{goal} or \texttt{goalw} and require no other
    27 Most proofs begin with \texttt{Goal} or \texttt{Goalw} and require no other
    28 commands than \texttt{by}, \texttt{chop} and \texttt{undo}.  They typically end
    28 commands than \texttt{by}, \texttt{chop} and \texttt{undo}.  They typically end
    29 with a call to \texttt{qed}.
    29 with a call to \texttt{qed}.
    30 \subsection{Starting a backward proof}
    30 \subsection{Starting a backward proof}
    31 \index{proofs!starting}
    31 \index{proofs!starting}
    32 \begin{ttbox} 
    32 \begin{ttbox}
    33 goal        : theory -> string -> thm list 
    33 Goal        :                       string -> thm list
       
    34 Goalw       :           thm list -> string -> thm list
       
    35 goal        : theory ->             string -> thm list 
    34 goalw       : theory -> thm list -> string -> thm list 
    36 goalw       : theory -> thm list -> string -> thm list 
    35 goalw_cterm : thm list -> cterm -> thm list 
    37 goalw_cterm : thm list -> cterm -> thm list 
    36 premises    : unit -> thm list
    38 premises    : unit -> thm list
    37 \end{ttbox}
    39 \end{ttbox}
    38 The \texttt{goal} commands start a new proof by setting the goal.  They
    40 
    39 replace the current state list by a new one consisting of the initial proof
    41 The goal commands start a new proof by setting the goal.  They replace
    40 state.  They also empty the \ttindex{undo} list; this command cannot be
    42 the current state list by a new one consisting of the initial proof
    41 undone!
    43 state.  They also empty the \ttindex{undo} list; this command cannot
       
    44 be undone!
    42 
    45 
    43 They all return a list of meta-hypotheses taken from the main goal.  If
    46 They all return a list of meta-hypotheses taken from the main goal.  If
    44 this list is non-empty, bind its value to an \ML{} identifier by typing
    47 this list is non-empty, bind its value to an \ML{} identifier by typing
    45 something like
    48 something like
    46 \begin{ttbox} 
    49 \begin{ttbox} 
    47 val prems = goal{\it theory\/ formula};
    50 val prems = goal{\it theory\/ formula};
    48 \end{ttbox}\index{assumptions!of main goal}
    51 \end{ttbox}\index{assumptions!of main goal}
    49 These assumptions serve as the premises when you are deriving a rule.
    52 These assumptions typically serve as the premises when you are
    50 They are also stored internally and can be retrieved later by the
    53 deriving a rule.  They are also stored internally and can be retrieved
    51 function \texttt{premises}.  When the proof is finished, \texttt{qed}
    54 later by the function \texttt{premises}.  When the proof is finished,
    52 compares the stored assumptions with the actual assumptions in the
    55 \texttt{qed} compares the stored assumptions with the actual
    53 proof state.
    56 assumptions in the proof state.
       
    57 
       
    58 The capital versions of \texttt{Goal} are the basic user level
       
    59 commands and should be preferred over the more primitive lowercase
       
    60 \texttt{goal} commands.  Apart from taking the current theory context
       
    61 as implicit argument, the former ones try to be smart in handling
       
    62 meta-hypotheses when deriving rules.  Thus \texttt{prems} have to be
       
    63 seldom bound explicitly, the effect is as if \texttt{cut_facts_tac}
       
    64 had been called automatically.
    54 
    65 
    55 \index{definitions!unfolding}
    66 \index{definitions!unfolding}
    56 Some of the commands unfold definitions using meta-rewrite rules.  This
    67 Some of the commands unfold definitions using meta-rewrite rules.  This
    57 expansion affects both the initial subgoal and the premises, which would
    68 expansion affects both the initial subgoal and the premises, which would
    58 otherwise require use of \texttt{rewrite_goals_tac} and
    69 otherwise require use of \texttt{rewrite_goals_tac} and
    59 \texttt{rewrite_rule}.
    70 \texttt{rewrite_rule}.
    60 
    71 
    61 \begin{ttdescription}
    72 \begin{ttdescription}
       
    73 \item[\ttindexbold{Goal} {\it formula};] begins a new proof, where
       
    74   {\it formula\/} is written as an \ML\ string.
       
    75   
       
    76 \item[\ttindexbold{Goalw} {\it defs} {\it formula};] is like
       
    77   \texttt{Goal} but also applies the list of {\it defs\/} as
       
    78   meta-rewrite rules to the first subgoal and the premises.
       
    79   \index{meta-rewriting}
       
    80 
    62 \item[\ttindexbold{goal} {\it theory} {\it formula};] 
    81 \item[\ttindexbold{goal} {\it theory} {\it formula};] 
    63 begins a new proof, where {\it theory} is usually an \ML\ identifier
    82 begins a new proof, where {\it theory} is usually an \ML\ identifier
    64 and the {\it formula\/} is written as an \ML\ string.
    83 and the {\it formula\/} is written as an \ML\ string.
    65 
    84 
    66 \item[\ttindexbold{goalw} {\it theory} {\it defs} {\it formula};] 
    85 \item[\ttindexbold{goalw} {\it theory} {\it defs} {\it formula};] 
   156   using \texttt{get_thm} (see \S\ref{BasicOperationsOnTheories}).
   175   using \texttt{get_thm} (see \S\ref{BasicOperationsOnTheories}).
   157   
   176   
   158 \item[\ttindexbold{store_thm} ($name$, $thm$)]\index{theorems!storing}
   177 \item[\ttindexbold{store_thm} ($name$, $thm$)]\index{theorems!storing}
   159   stores $thm$ in the theorem database associated with its theory and
   178   stores $thm$ in the theorem database associated with its theory and
   160   returns that theorem.
   179   returns that theorem.
       
   180 \end{ttdescription}
       
   181 
       
   182 
       
   183 \subsection{Extracting axioms and stored theorems}
       
   184 \index{theories!axioms of}\index{axioms!extracting}
       
   185 \index{theories!theorems of}\index{theorems!extracting}
       
   186 \begin{ttbox}
       
   187 thm       : xstring -> thm
       
   188 thms      : xstring -> thm list
       
   189 get_axiom : theory -> xstring -> thm
       
   190 get_thm   : theory -> xstring -> thm
       
   191 get_thms  : theory -> xstring -> thm list
       
   192 axioms_of : theory -> (string * thm) list
       
   193 thms_of   : theory -> (string * thm) list
       
   194 assume_ax : theory -> string -> thm
       
   195 \end{ttbox}
       
   196 \begin{ttdescription}
       
   197   
       
   198 \item[\ttindexbold{thm} $name$] is the basic user function for
       
   199   extracting stored theorems from the current theory context.
       
   200   
       
   201 \item[\ttindexbold{thms} $name$] is like \texttt{thm}, but returns a
       
   202   whole list associated with $name$ rather than a single theorem.
       
   203   Typically this will be collections stored by packages, e.g.\ 
       
   204   \verb|list.simps|.
       
   205 
       
   206 \item[\ttindexbold{get_axiom} $thy$ $name$] returns an axiom with the
       
   207   given $name$ from $thy$ or any of its ancestors, raising exception
       
   208   \xdx{THEORY} if none exists.  Merging theories can cause several
       
   209   axioms to have the same name; {\tt get_axiom} returns an arbitrary
       
   210   one.  Usually, axioms are also stored as theorems and may be
       
   211   retrieved via \texttt{get_thm} as well.
       
   212   
       
   213 \item[\ttindexbold{get_thm} $thy$ $name$] is analogous to {\tt
       
   214     get_axiom}, but looks for a theorem stored in the theory's
       
   215   database.  Like {\tt get_axiom} it searches all parents of a theory
       
   216   if the theorem is not found directly in $thy$.
       
   217   
       
   218 \item[\ttindexbold{get_thms} $thy$ $name$] is like \texttt{get_thm}
       
   219   for retrieving theorem lists stored within the theory.  It returns a
       
   220   singleton list if $name$ actually refers to a theorem rather than a
       
   221   theorem list.
       
   222   
       
   223 \item[\ttindexbold{axioms_of} $thy$] returns the axioms of this theory
       
   224   node, not including the ones of its ancestors.
       
   225   
       
   226 \item[\ttindexbold{thms_of} $thy$] returns all theorems stored within
       
   227   the database of this theory node, not including the ones of its
       
   228   ancestors.
       
   229   
       
   230 \item[\ttindexbold{assume_ax} $thy$ $formula$] reads the {\it formula}
       
   231   using the syntax of $thy$, following the same conventions as axioms
       
   232   in a theory definition.  You can thus pretend that {\it formula} is
       
   233   an axiom and use the resulting theorem like an axiom.  Actually {\tt
       
   234     assume_ax} returns an assumption; \ttindex{qed} and
       
   235   \ttindex{result} complain about additional assumptions, but
       
   236   \ttindex{uresult} does not.
       
   237 
       
   238 For example, if {\it formula} is
       
   239 \hbox{\tt a=b ==> b=a} then the resulting theorem has the form
       
   240 \hbox{\verb'?a=?b ==> ?b=?a  [!!a b. a=b ==> b=a]'}
   161 \end{ttdescription}
   241 \end{ttdescription}
   162 
   242 
   163 
   243 
   164 \subsection{Retrieving theorems}
   244 \subsection{Retrieving theorems}
   165 \index{theorems!retrieving}
   245 \index{theorems!retrieving}