Given a set of rules which are a logical intersection of some known values (groups, types, properties) that combine to give some value as follows:
group1 AND type1 AND property1 = value1
group1 AND type1 AND property2 = value2
group1 AND type1 AND property3 = value3
group1 AND type2 AND property1 = value1
group1 AND type2 AND property4 = value1
group2 AND type1 AND property2 = value2
And that the following hold true:
- The sets of group/type/property are finite and known
- A given rule in unique by the combination of group/type/property
- Many rules may reference a single value
How might I best approach finding an optimal solution for 'collapsing' these rules into a format where multiple values of the same group are combined (below) whilst maintaining the same logical interpretation of the original lookup?
(group1) AND (type1 OR type2) AND (property1) = value1
(group1 OR group2) AND (type1) AND (property2) = value2
(group1) AND (type1) AND (property3) = value3
(group1) AND (type2) AND (property4) = value1
Aim: the least number of rules which contain the same logical information as the original lookup.
An approach could be taking the original lookup 'keys', grouping by first value then two keys and collapsing on the distinct instances of the remaining key could be repeated for each combination of the keys. The results are headed in the right direction, but are not guaranteed to be optimal with the multi step approach.
Would appreciate any thoughts on a better approach, or pointers to reading if this is actually a generalised problem.
Happy to provide any clarification if required.
*Apologies for the clunky title - hopefully that describes the general problem
EDIT: I think this question (no concrete answer) expresses the problem as finding the Union of all intersecting sets.
EDIT 2: I should have said, the target form is actually a requirement, rather than the logically optimal solution from @timrau. The form is (groups) AND (types) AND (properties) => value
, where the groups/types/properties are represented with an OR only.