Logic optimization using rule-based randomized search