
The \REDUCE~  program  was the   first \CompHEP~ output 
which opened the possibility   to produce some physical results
by means of this package. Later on, 
when the \CompHEP~ built-in symbolic calculator was created,
the \REDUCE~ output  became unnecessary. But we still
keep it in the package for testing. 

The \CompHEP~ symbolic calculator  looks like a black box.
On the contrary the \REDUCE~ program is written in terms which
can be understood and checked. The comparison of result 
produced by the built-in symbolic calculator with that of
 \REDUCE~   evaluation of the generated code
is a good check of  \CompHEP~  software (see Section  \ref{symb-calc-check}).
  Below we shall describe 
the structure  of \REDUCE~ program.
  
\CompHEP~ generates a separate file for each squared diagram.
 The files are named as  {\it pNNN-MMM.red} where 
{\it NNN} is  the  subprocess number 
and {\it MMM} is the  diagram ordering number. 

The file begins with from the declaration of momenta and Lorentz indices.
For example,\\

\begin{verbatim}
% ----------- VARIABLES ------------------ 
 vector  A,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,ZERO_;
 vector  m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,m12,m13,m14,m15,m16;
%
%--------- Mass shell declarations -----------
 MASS  P1 = 0$  MSHELL P1$
 MASS  P2 = 0$  MSHELL P2$
 MASS  P3 = Mm$  MSHELL P3$
 MASS  P4 = Mm$  MSHELL P4$

%-------- Momentum substitutions --------
 Let  p4 = +p1+p2-p3$
 Let  p5 = +p1+p2$
 Let  p6 = -p1-p2$

\end{verbatim}

Vector {\it A} is used by the \REDUCE~ package  to construct 
the $\gamma^{5}$ matrix, $\gamma^{5}=G(ln,A)$. Vectors  whose names begin
 with {\tt 'p'} are used for designation of momenta. Vectors whose names begin
with {\tt 'm'} are reserved for Lorentz indices.
We see then the  mass-shell declarations for incoming and outgoing particles.
After that the file contains the substitutions of momenta of on-shell and 
virtual particles  which we have according to the  conservation law.


Then the diagram total factor  with self explanatory 
comments is written down. For example, in the case of $e^+ e^- \rightarrow \mu^+ \mu^-$
process we have 
\begin{verbatim}
%---------- Factors ---------------
 SymmFact:=1/1$    % Diagram symmetry factor
 AverFact:=1/4$       % Normalization factor of polarization average
 FermFact:=1$      % (-1)**(number of in-fermion particles)
 ColorFact:=1/1$    %  QCD color weight of diagram  
%
totFactor_:=EE**4$
totFactor_:=totFactor_*SymmFact*AverFact*FermFact*ColorFact$
\end{verbatim}

These declarations are self-explanatory except, maybe, of the $SymmFact$
variable. Generally   $SymmFact=N/D$  where  $N$ is equal to 1 in the 
case of   left-right    squared diagram   symmetry. Otherwise
the factor equals  2.  $D$ is a factorial connected with presence  of 
identical  outgoing particles and  partially reduced by a number of various 
possibilities to assign the momenta  of outgoing particles to the 
corresponding diagram lines. 


The  program for evaluation of  one squared diagram actually  
includes  the codes for a set of diagrams which appear after
replacing of some physical particles by their ghosts according to the
existing interaction  vertices. 
We shall call all diagrams of the set as {\it ghost} diagrams.
Note that all these  diagrams have the same denominator. 
The evaluation is started from the initialization of
variable for the sum of numerators of the set:

{\tt numerator\_:=0\$}

The program for evaluating  each  diagram of the set is advanced by  the 
 pseudo-graphical image of diagram. (See, for example, Fig.\ref{pseudo}).
  The name of particle and corresponding momentum are written down near
the line. The Lorentz index is written just on the line.

The diagram code is started from the fermion loops evaluation.
The program moves along the  fermion line and multiplies 
the vertex and propagator terms. The    $nospur$ 
instruction is declared before each loop  evaluation to prevent
the default trace evaluation in the end of any instruction.


If  the result of multiplication contains
 Lorentz indices which can  be contracted, the program 
declares the corresponding  vectors as indices by means of 
the  {\it index  }  instruction.

As a rule the  fermion  vertices are multiplied 
in the order which corresponds to moving in the direction
opposite to the direction of fermion arrows. But if the  diagram  
contains a vertex with the {\it C-conjugate} operator or
Majorana particles the order of multiplication is chosen at random, 
because the propagator lines have different orientations or have no them at all. 
If the orientation of fermion line is chosen,  the  vertices 
are divided into two groups, normal and reverse. For the normal vertex the 
incoming fermion line is attached to the second fermion,
 whereas for the reverse  vertex it is attached to the  first one.
 \CompHEP~ transforms the reverse vertices to normal form by means 
of the rule (\ref{reverse}) and writes down the  corresponding comment.

After the last multiplication the state of the $spur$ switch is 
restored and the $\gamma$-matrix trace   is evaluated  with simultaneous 
multiplication by factor of '-4'. The '4' is needed because the \REDUCE~
trace evaluation omits this factor and the minus  appears from 
the Feynman rules.

The next step  is the  multiplication of vertices 
and contraction of   Lorentz indices . The indices for contraction 
are declared by the {\it Index } instruction before the 
multiplication. The fragment of the corresponding code looks like \\

\begin{verbatim}
 Index m2$
 Vrt_3:=Vrt_3*Vrt_5$
 RemInd  m2$
\end{verbatim}    

This code means that the vertex number 3 is multiplied by the  vertex number 5
with contraction of $index\; m2$. The result of multiplication is 
considered as a   generalized vertex  number 3.

  Here we would like to note that there is a bug 
in the \REDUCE~ package which  forbids to  convolute  
several indices in one operation. To bypass this bug we declare the '$m$'
vectors as  indices step by step and recalculate the expression on each step. 

If two vertices are connected by a propagator of massive vector particle
treated  in the physical gauge (\ref{mvPropagator})  the code are organized 
in the following way.
\CompHEP~ writes the code for the vertices product with contracted  indices
and the code for the  product of the  same vertices with the prior multiplication by 
 relevent momentum. After that  these contributions are  summarized.  
Below we present an example of such a code:

\begin{verbatim}
 Index m1$
 Vrt_0:=Vrt_1*Vrt_2$
 RemInd  m1$
 Vrt_L:=Vrt_1$   Vrt_R:=Vrt_2$
 Vrt_L:=(Vrt_L where m1=>(+P2+P3)/MZ)$
 Vrt_R:=(Vrt_R where m1=>(+(-P2)+(-P3))/MZ)$
 Vrt_0:=Vrt_0 + Vrt_L*Vrt_R$
\end{verbatim}    

The code for any diagram  evaluation  is terminated by instruction
 $$ numerator\_:=numerator\_ +DiagramFactor*GhostFact*Vrt\_1 $$
which  summarizes the ghost diagram contributions.
Here  {\it GhostFact} equals  $(-1)^{l+v}$ where the $l$ is a number 
 of loops of Faddeev-Popov ghosts and $v$ is a number of  vector
field lines in the diagram. The $(-1)^{v}$  factor  appears because 
the evaluations discribed above correspond to substitution of the 
$(g_{\mu\nu} - k_{\mu}k_{\nu}/M^2)$ factor for the propagator and the density 
matrix of vector field  whearas the correct
expression has the opposite sign. 


The last step of the program is the assignment   of variable
$denominator\_$. It is expressed as a production of $propDen(P,Mass,Width)$
functions as it is explained in Section \ref{s-output}. 


As a result the symbolic answer for the evaluated diagram
may be presented in the form


$$ totFactor\_ \frac{ numerator\_}{denominator\_}\;.  $$


