implementation of ruleA, ruleA', ruleB, ruleB'