Find if a set fits another set, by applying its correspondent score to an equation?

50 Views Asked by At

Summary

Given that I have finite elements, each element has its score value, and a set A with some of those elements, which I can sum all the elements score to have a result, is it possible to determine if a set B is a subset of A or equals A, by an equation, using the scores?

A real world scenario

[big windows, white color, black color, pool, garden, garage, two floors]

[1, 2, 4, 8, 16, 32, 64]

My elements are the house features with their correspondent score. A set would be a house.

I have a finite list of house features represented in the first array. Also, each feature has its value, defined in the second array respectively.

A buyer wants to find a house with big windows, garage and two floors. So, if I sum his features requirements values, I will have 1+32+64= 97. Then I have a house with the features big windows, white color, garage and two floors. The sum of this house features is 1+2+32+64=99. Even though the 2 sums are not the same, that house fits the buyer conditions.

  1. Is it possible to create an equation that given a house with its features, and a buyer with their requirements, by its result I can find out it the house fits the buyer needs?

  2. Also, is it possible to apply AND / OR / AND NOT IN / OR NOT IN conditions to the buyer requirements? Ie. Big windows, (white color or has a pool) but not garage.

What I am trying to achieve

Given a rule, which is a combination of house features, find a function that results in a unique score for the rule.

Given a set, a house, find a function that when applied to a rule, results true if the house fits the rule (a house can have more features than the rule), or false if the house doesn't fit the rule.

If this is an existing topic in mathematics, may I get its name so I can study it?

Undergoing solution

As @SenZen suggested, if each feature has an unique prime number, I can find if a set of features fits a house by dividing their products. For the NOT condition I do the same but applying the reversed truth table (I want to find !(true), which is, it cant be divisible by the product of NOT primes).

The blocker that I face is, mapping features to a prime number. I have 5K features, and sometimes new ones can be added. So given a prime number, I will need to find the next prime to attribute to the new feature.