As an example for the rules
Given an RGB = (R,G,B) where R,G,B are integers between 0 and 255 and a distance D (the distance is a distance away from the other colors so that the color isn't white or something)
A rule for a primary color could be:
Primary(RGB) = there exists a number C in RGB such that for All X in RGB, X != C implies C >= X + D .
This would mean that the color would be a primary color.
You could also turn it into 3 separate rules if you want.
Red(RGB) = For All X in RGB, X != R implies R >= X + D
(Replace R with B and G for Blue and Green)
So if D was 40 you could say the set (80,40,40) is red.
A rule for Secondary colors could be
Secondary(RGB) = there exists a number C in RGB such that for All X in RGB, X != C implies X >= C + D .
A rule for a black-to-grey-to-white color would be
BlackOrWhite(RGB) = for all X in RGB, For all Y in RGB, AbsoluteValue(X -Y) <= D .
(Funnily enough you don't need the absolute value qualification for this rule but It's still good form to keep it)
The main assumption I made for these rules was that you just had to add a distance between the number to figure out what color it is. Also the rules aren't complete because you have colors like pink (light red) or magenta (light purple). Also the rules aren't correct for the primary and secondary colors because you could have something like (40,40,40) be vacuously true since X != C would be false all 3 times so you would never get to the other condition. You would need add another condition or add more data to the tuple (What I would do) to actually get the rule. But those rules basically give you the right meaning the other conditions are just technicalities. I am done wasting my time on this question.