add is_permutation algorithm: robust version (N3607)