Proof with auto with arith; try omega.
induction x; intros.
simpl. omega.
rename a into h, x into t.
rewrite foldlM_cons.
rewrite bind_cost.
deep_le_trans (insert_cost y h)...
apply plus_le_compat...
apply insert_cost.
deep_le_trans (IHx (result (insert _ mle y h)))...
clear IHx.
rewrite insert_length...
simpl @length.
simpl mult.
rewrite <- mult_n_Sm.
apply le_trans with ((length y * length t + length y) + (length t + div2 (sqrd (length t))))...
apply plus_le_compat_l.
rewrite plus_comm.
apply div2_sqrdSn.
Qed.

Theorem insertion_sort_quadratic: forall (l: list T),
cost (isort _ mle l) <= div2 (sqrd (length l)).