\resetsteps      % Reset all the commands to create a blank worksheet  

% Define the operation to be computed

\renewcommand{\operation}{ \alpha := \mbox{Sum}( x ) }

% Step 1a: Precondition 

\renewcommand{\precondition}{
  \alpha = \hat{\alpha}
}

% Step 1b: Postcondition 

\renewcommand{\postcondition}{ 
  \alpha = \mbox{Sum}( x )
}

% Step 2: Invariant 
% Note: Right-hand side of equalities must be updated appropriately

\renewcommand{\invariant}{
\alpha = \mbox{Sum}( x_T )
}

% Step 3: Loop-guard 

\renewcommand{\guard}{
  n( x_T ) \neq n( x )
}

% Step 4: Initialize 

\renewcommand{\partitionings}{
  $
  x \rightarrow
  \FlaTwoByOne
     {x_T}
     {x_B}
  $
\\
  $ \alpha = 0 $
}

\renewcommand{\partitionsizes}{
$ x_T $ has $ 0 $ elements
}

% Step 5a: Repartition the operands 

\renewcommand{\repartitionings}{
$
  \FlaTwoByOne
    {x_T}
    {x_B}
\rightarrow  
  \FlaThreeByOneB
    {x_0}
    {\chi_1}
    {x_2}
$
}


\renewcommand{\repartitionsizes}{
$ \chi_1 $ is a scalar
}

% Step 5b: Move the double lines 

\renewcommand{\moveboundaries}{
$
  \FlaTwoByOne
    {x_T}
    {x_B}
\leftarrow  
  \FlaThreeByOneT
    {x_0}
    {\chi_1}
    {x_2}
$
}

% Step 6: State after repartitioning
% Note: The below needs editing!!!

\renewcommand{\beforeupdate}{
\alpha = \mbox{Sum}( x_0 )
}

% Step 7: State after moving of double lines
% Note: The below needs editing!!!

\renewcommand{\afterupdate}{
\alpha = \mbox{Sum}( x_0 ) + \chi_1
}

% Step 8: Insert the updates required to change the 
%         state from that given in Step 6 to that given in Step 7
% Note: The below needs editing!!!

\renewcommand{\update}{
$
  \begin{array}{l}
  \alpha \becomes \alpha + \chi_1
  \end{array}
$
}

\begin{figure}[tbp]

\begin{center}     % center the algorithm on the page 
\footnotesize      % make the font smaller so things fit on a page 
 
\worksheet         % this command generates the worksheet using the 
                   % commands that were defined between the \resetsteps 
                   % and the worksheet command 
\end{center} 
 
% The following command creates a caption for the figure. 
 
\caption{Worksheet for deriving an algorithm for summing the elements 
of a vector $ x $ (Variant 1).} 
 
 
% The following command creates a label so that the figure can 
% be referenced by its number by inserting  
%  \ref{fig:sum} in the \LaTeX source 
 
\label{fig:sum}
 
\end{figure} 

