views:

87

answers:

2

Hey!

I need a library/algorithm that can transform an arbitrary logical expression that contains range predicates into a reduced disjoint normal form.

Example : (x > 40) & ( (x > 50) | (y > 10)) -> (x > 50) | (x > 40) & (y > 10)

Basically, what I want to simply such an expression in order to evaluated as fast as possible.

Anyone can help me?

A: 

Tools like ANTLR will help you to build a parse tree for your expression. You might be able to then "flatten" the tree based on the commutative properties of your operators. I don't personally know of an algorithm or library that will do this.

Matt Baker
A: 

Wolfram Alpha handles your expression pretty well:

see here.

... meaning that Mathematica is suitable for doing this, out of the box. However, you probably don't want to use that big a program for such a relatively simple problem.

Carl Smotricz