COND_REWR_TAC is one of the basic building blocks for the
implementation of conditional rewriting in the HOL system. In
particular, the conditional term replacement or rewriting done by all
the built-in  conditional
rewriting tactics is ultimately done by applications of
COND_REWR_TAC.  The description given here for COND_REWR_TAC may
therefore be taken as a specification of the atomic action of
replacing equals by equals in the goal under certain conditions that
aare used in all these higher level conditional rewriting tactics.
The first argument to COND_REWR_TAC is expected to be a function
which returns a list of matches. Each of these matches is in the form
of the value returned by the built-in function match. It is used to
search the goal for instances which may be rewritten.
The second argument to COND_REWR_TAC is expected to be an implicative theorem
in the following form:
   A |- !x1 ... xn. P1 ==> ... Pm ==> (Q[x1,...,xn] = R[x1,...,xn])
If fn is a function and th is an implicative theorem of the kind
shown above, then COND_REWR_TAC fn th will be a tactic which returns
a list of subgoals if evaluating
returns a non-empty list of matches when applied to a goal
(asm,gl).
Let ml be the match list returned by evaluating fn Q[x1,...,xn] gl.
Each element in this list is in the form of
   ([(e1,x1);...;(ep,xp)], [(ty1,vty1);...;(tyq,vtyq)])
For each match in ml, COND_REWR_TAC will perform the following:
1) instantiate the input theorem th to get
   th' = A |- P1' ==> ... ==> Pm' ==> (Q' = R')
   asm ?- Pk'  ...  asm ?- Pm'   {{asm,Pk',...,Pm'}} ?- gl'
If COND_REWR_TAC is given a theorem th:
   A |- !x1 ... xn y1 ... yk. P1 ==> ... ==> Pm ==> (Q = R)
   th'' = A |- P1'' ==> ... ==> Pm'' ==> (Q' = R'')