Hacker News new | ask | show | jobs
by saynsedit 3602 days ago
One litmus test to check the usefulness of an abstraction is to see if it conforms to existing laws of the specific case.

Let's use distributivity of AND over OR:

    a & (b | c) = a & b | a & c
This also works in the abstraction of Boolean algebra to normal algebra:

    a * (b + c) = a * b + a * c
What about with your digit MIN/MAX abstraction:

    MIN(a,MAX(b,c)) = MIN(MAX(a,b),MAX(a,c))
Well... No, this does not generally hold. If b and c are both larger than a, then this equality fails.

Distributivity is a pretty important property. Without it, your MIN/MAX algebra just has commutivity and associativity which arguably aren't very unique considering all other possible commutive/associative functions. In any case, losing a property dramatically decreases the usefulness of your algebraic abstraction.

Another wart in your abstraction is the missing NOT operation, further deteriorating its usefulness.

Just because the MIN abstraction works for the AND case, that's not enough to make it a worthwhile abstraction. What happens when you want to do more complex yet natural operations like a & (b | c)? In the same vein, AbstractManagerFactoryFactory may seem elegant now, but it may make it harder for new code to do trivial things down the road.

1 comments

I think it works, if you do it right:

  MIN(a,MAX(b,c)) = MAX(MIN(a,b),MIN(a,c))
It does, I stand corrected.
And so does

  MAX(a,MIN(b,c)) = MIN(MAX(a,b),MAX(a,c))
so it is even more useful than normal algebra :p
Fuzzy logic has insane amounts of similar ORs and ANDs that also have to conform some simple laws.

Generalization of ANDs and ORs is called t-norms and t-conorms (s-norms). They have to satisfy laws of monotonicity, commutativity and associativity.

So all kinds of magical ANDs and ORs spawn to meet the requirements.

I'm not really a fan of fuzzy logic but it really is a nice exercise in mathematics.