*
*   Master include file for the bfn programs that compute S(R(...),inf)
*   for weight n. The algorithm is explained in bf2.frm
*   File by J. Vermaseren 5-jun-1998
*
CF  Er,E,EE,EEE;
S   s6,s7a,s7b;
*
*   Include the tables for the lower weights.
*
#call tables(`SIZE'-1)
*
*   Now the various procedures. They are here in the header file to allow
*   them to be loaded in memory. That makes things a bit quieter.
*
#procedure clean(type)
*
*   The handling of the equations once they have been properly constructed
*   First convert back to 'table notation' of equation 8 in the paper
*
  id  S(R(?a),inf) = S(?a);
  repeat id S(?a,n?{2,...,`MAXWEIGHT'},?b) = S(?a,0,n-1,?b);
  repeat id S(?a,n?{<-2>,...,<-`MAXWEIGHT'>},?b) = S(?a,0,n+1,?b);
*
*   Substitute all S-functions with a lower weight.
*   Done by table lookup. This is rather fast.
*
  #do k = 1,`SIZE'-1
    id  SS(n1?,...,n`k'?) = Stab`k'(n1,...,n`k');
  #enddo
*
*   Now some trick to be able to substitute the S-functions of the proper
*   weight by the contents of the appropriate bracket in FF.
*
  id  S(?a) = R(E(?a));
  id  R(n?$n) = FF[$n];
*
*   Bracket in S so that we may take the first bracket
*
  B   S;
 .sort: setup(`type')-`$count';
*
*   take only action if F is not trivial!
*
  #if ( termsin(F) != 0 )
*
*   after this we do not need F any longer. We operate on FF.
*
    Drop F;
*
*   Put the first bracket in $fb. The content of that bracket in $fv
*   This content should be a number.
*   Now put the rhs of the substitution in $fr, properly normalized.
*   This is all done in compile time.
*
    #$fb = FirstBracket_(F);
    #$fv = F[$fb];
    #$fr = -F/(`$fv')+`$fb';
*
*   Create the proper substitution for action on FF.
*
    id `$fb' = $fr;
*
*   and bracket FF again for the next pass.
*
    B   E;
    .sort:substitution(`type')-`$dcount';
*
*   One variable fewer to go:
*
    #$dcount = $dcount-1;
  #endif
#endprocedure
*
#procedure solve1
*
*   Procedure for equations based on the shuffle algebra.
*   Based on the reduction to the basis (see appendix A).
*   EE*EE defines an equation. (SS*SS-S*S = 0)
*   In the S*S we convert to the proper notation for the indices.
*   Then we apply the basis routine.
*   Then clean does the rest (see in clean (above))
*
  id  EE(?a)*EE(?b) = SS(?a)*SS(?b)
                     -S(R(?a),inf)*S(R(?b),inf);
  repeat id S(R(?a,0,n?,?b),inf) = S(R(?a,n+sig_(n),?b),inf);
  #call basis(S)
  #call clean(1)
#endprocedure
*
#procedure solve2
*
*   Procedure for equations based on the theorem.
*   EEE*EEE defines the equation SS*SS - sum = 0
*   We convert the S functions in the sum to the standard notation.
*   Then we write the second S function properly (to get the denominator)
*   The sum is done (routine sumnmii)
*   Then clean does the rest (see in clean (above))
*
  id  EEE(?a)*EEE(?b) = SS(?a)*SS(?b)
                       -sum1(j1,1,inf)*S1(R(?a),inf,-j1)*S2(R(?b),j1);
  repeat id S1(R(?a,0,n?,?b),?c) = S1(R(?a,n+sig_(n),?b),?c);
  repeat id S2(R(?a,0,n?,?b),?c) = S2(R(?a,n+sig_(n),?b),?c);
  id  S2(R(n?,?a),j1) = S1(R(?a),0,j1)*den1(abs_(n),0,j1)*sign1(j1)^theta_(-n);
  id  S1(R,0,j1) = 1;
  #call sumnmii(1)
  #call clean(2)
#endprocedure
*
#procedure subconst(weight)
*
*   Substitutes the 'independent objects' at a given weight
*   Of course some of these things come in hindsight......
*   The zi are zeta functions: zi = \zeta_i
*   linhalf = Li_n(1/2)
*
  #if `weight' >= 1
    id  S(1) = Sinf;
    id  S(-1)= -ln2;
  #endif
  #if `weight' >= 2
    id  S(0,1) = z2;
  #endif
  #if `weight' >= 3
    id  S(0,0,1) = z3;
  #endif
  #if `weight' >= 4
    id  S(-1,1,1,1) = -li4half;
  #endif
  #if `weight' >= 5
    id  S(-1,1,1,1,1) = -li5half;
    id  S(0,0,0,0,1) = z5;
  #endif
  #if `weight' >= 6
    id  S(-1,1,1,1,1,1) = -li6half;
    id  S(0,0,0,0,-1,-1) = s6;
  #endif
  #if `weight' >= 7
    id  S(-1,1,1,1,1,1,1) = -li7half;
    id  S(0,0,0,0,0,0,1) = z7;
    id  S(0,0,0,0,-1,1,1) = s7a;
    id  S(0,0,0,0,1,-1,-1) = s7b;
  #endif
#endprocedure


