solve deep rewrites in function rules in java backend