doc-src/Ref/simplifier.tex
changeset 45645 4014bc2a09ff
parent 42925 c6c4f997ad87
equal deleted inserted replaced
45644:8634b4e61b88 45645:4014bc2a09ff
   332   There is basically no restriction on the form of the right-hand
   332   There is basically no restriction on the form of the right-hand
   333   sides.  They may not contain extraneous term or type variables,
   333   sides.  They may not contain extraneous term or type variables,
   334   though.
   334   though.
   335 \end{warn}
   335 \end{warn}
   336 \index{rewrite rules|)}
   336 \index{rewrite rules|)}
   337 
       
   338 
       
   339 \subsection{*Congruence rules}\index{congruence rules}\label{sec:simp-congs}
       
   340 \begin{ttbox}
       
   341 addcongs   : simpset * thm list -> simpset \hfill{\bf infix 4}
       
   342 delcongs   : simpset * thm list -> simpset \hfill{\bf infix 4}
       
   343 addeqcongs : simpset * thm list -> simpset \hfill{\bf infix 4}
       
   344 deleqcongs : simpset * thm list -> simpset \hfill{\bf infix 4}
       
   345 \end{ttbox}
       
   346 
       
   347 Congruence rules are meta-equalities of the form
       
   348 \[ \dots \Imp
       
   349    f(\Var{x@1},\ldots,\Var{x@n}) \equiv f(\Var{y@1},\ldots,\Var{y@n}).
       
   350 \]
       
   351 This governs the simplification of the arguments of~$f$.  For
       
   352 example, some arguments can be simplified under additional assumptions:
       
   353 \[ \List{\Var{P@1} \bimp \Var{Q@1};\; \Var{Q@1} \Imp \Var{P@2} \bimp \Var{Q@2}}
       
   354    \Imp (\Var{P@1} \imp \Var{P@2}) \equiv (\Var{Q@1} \imp \Var{Q@2})
       
   355 \]
       
   356 Given this rule, the simplifier assumes $Q@1$ and extracts rewrite
       
   357 rules from it when simplifying~$P@2$.  Such local assumptions are
       
   358 effective for rewriting formulae such as $x=0\imp y+x=y$.  The local
       
   359 assumptions are also provided as theorems to the solver; see
       
   360 {\S}~\ref{sec:simp-solver} below.
       
   361 
       
   362 \begin{ttdescription}
       
   363   
       
   364 \item[$ss$ \ttindexbold{addcongs} $thms$] adds congruence rules to the
       
   365   simpset $ss$.  These are derived from $thms$ in an appropriate way,
       
   366   depending on the underlying object-logic.
       
   367   
       
   368 \item[$ss$ \ttindexbold{delcongs} $thms$] deletes congruence rules
       
   369   derived from $thms$.
       
   370   
       
   371 \item[$ss$ \ttindexbold{addeqcongs} $thms$] adds congruence rules in
       
   372   their internal form (conclusions using meta-equality) to simpset
       
   373   $ss$.  This is the basic mechanism that \texttt{addcongs} is built
       
   374   on.  It should be rarely used directly.
       
   375   
       
   376 \item[$ss$ \ttindexbold{deleqcongs} $thms$] deletes congruence rules
       
   377   in internal form from simpset $ss$.
       
   378   
       
   379 \end{ttdescription}
       
   380 
       
   381 \medskip
       
   382 
       
   383 Here are some more examples.  The congruence rule for bounded
       
   384 quantifiers also supplies contextual information, this time about the
       
   385 bound variable:
       
   386 \begin{eqnarray*}
       
   387   &&\List{\Var{A}=\Var{B};\; 
       
   388           \Forall x. x\in \Var{B} \Imp \Var{P}(x) = \Var{Q}(x)} \Imp{} \\
       
   389  &&\qquad\qquad
       
   390     (\forall x\in \Var{A}.\Var{P}(x)) = (\forall x\in \Var{B}.\Var{Q}(x))
       
   391 \end{eqnarray*}
       
   392 The congruence rule for conditional expressions can supply contextual
       
   393 information for simplifying the arms:
       
   394 \[ \List{\Var{p}=\Var{q};~ \Var{q} \Imp \Var{a}=\Var{c};~
       
   395          \neg\Var{q} \Imp \Var{b}=\Var{d}} \Imp
       
   396    if(\Var{p},\Var{a},\Var{b}) \equiv if(\Var{q},\Var{c},\Var{d})
       
   397 \]
       
   398 A congruence rule can also {\em prevent\/} simplification of some arguments.
       
   399 Here is an alternative congruence rule for conditional expressions:
       
   400 \[ \Var{p}=\Var{q} \Imp
       
   401    if(\Var{p},\Var{a},\Var{b}) \equiv if(\Var{q},\Var{a},\Var{b})
       
   402 \]
       
   403 Only the first argument is simplified; the others remain unchanged.
       
   404 This can make simplification much faster, but may require an extra case split
       
   405 to prove the goal.  
       
   406 
   337 
   407 
   338 
   408 \subsection{*The subgoaler}\label{sec:simp-subgoaler}
   339 \subsection{*The subgoaler}\label{sec:simp-subgoaler}
   409 \begin{ttbox}
   340 \begin{ttbox}
   410 setsubgoaler :
   341 setsubgoaler :