generate rule matrix