Automated Diagnosis for Digital Circuits