partition(S,p) is
{@$S.0..m-1\in Int \land m\ge 0$@}

@$\bb$@ Var B.0..m-1 @$\in$@ Int; i,j @$\in$@ Int;
   initially B=S @$ \land $@ i=1 @$ \land $@ j=1  
   do @$\{P\}$@ 
     B @$\rightarrow$@  if @$\{P\land B\}$@
              @$B_0$@ @$\rightarrow$@ @$\{P\land B \land B_0\}S_0\{P\}$@
             @$\assync$@ @$B_1$@ @$\rightarrow$@ @$\{P\land B\land B_1\}S_1\{P\}$@
           fi @$\{P\}$@
   od
   @$\{P \land \neg B\}$@
   S.0,S(i-1),p:=S(i-1),S.0,i-1
   @$\{R \}$@
@$\be$@
