Rule-based optimization with K-framework