swapsec(S,p,q,n) is
{@$m\ge0 \land S.0..m-1\in Int \land p,q,n\in Int \land n\ge 0$@}
@$\bb$@ Var k @$\in$@ Int;
   initially B=S @$ \land $@ i=0 @$ \land $@ m@$ \ge $@0 @$ \land $@ n@$ \ge $@0
   @$\{P\}$@
   do 
     n-k@$>$@0 @$\rightarrow$@ S(p+k),S(q+k),k:=S(q+k),S(p+k),k+1
   od
   @$\{P \land \neg B\}$@

  @$\{R \}$@
@$\be$@
