Error using the cofac() function of UFL

It is unclear to me how you have gotten that version of ufl for the Legacy release of Dolfin.
For legacy dolfin you should now use ufl_legacy: Announcement: ufl_legacy and legacy dolfin