insertionsort(S,m) is
@$\bb$@ Const B.0..m-1 @$\in$@ Int; 
   Var i @$\in$@ Int;
   initially B=S @$ \land $@ i=0 @$ \land $@ m@$ \ge $@0
   @$\{\text{invariant }P\}$@
   @$\{\text{bound } T \}$@
   do 
     @$G$@: m-i @$>$@ 0: insert(S,i)
                    ;i:=i+1
   od
   @$\{P \land \neg B\}$@

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


insert(S,i) is
@$\bb$@ Var j,tmp @$\in$@ Int;
   initially j=i @$ \land $@ tmp=S.i
   do 
      j @$>$@ 0: S.j,j:=S.j-1,j-1
   od
@$\be$@


