A Formal Framework for the Specification, Verification and Synthesis of Diagnosers