Logic inversion