Optimal Discrimination between Transient and Permanent Faults - Mathematical Details