Three-level logic synthesis : algebraic approach and minimization algorithms