write algorithms in new format

+ update environments for theorems