views:

64

answers:

1

I'm doing some work on a Complex Event Processing system. It supports filtering of sets of records based on members of those records, using a query language. The language supports logical, arithmetic and user-defined operators over arbitrary members.

Here's an example of a supported query:

( MemberA > MemberB ) && 
( @in MemberC { "str1", "str2" } ) &&
( com.foo.Bar.myPred( MemberD, MemberE ) )

My problem is that I want to combine queries into one super query, and then I want to optimize that super query to eliminate redundancies, tautologies and contradictions. e.g. I want to take

A > 0

and combine it with

A > 1

which is quite easy:

A > 0 || A > 1

but then I want to optimize it so that it reduces to

A > 0

If there are any URLs or books that discuss this general topic, I'd appreciate knowing about them.

A: 

Books? I think there's a few; and most likely you should look up for articles in this area.

What you may look at are SMT solvers that can work with your domain of queries. You feed them with the mathematicalized definition of your expression language, state axioms of the relations you support. Then they can, for instance, reason if (yes, two equal conjunctions) whether one predicate implies another is a tautology.

Note that the automated solutions to this task are vague and sometimes are beyond the theoretical capabilities of Turing machines (i.e. computer). You won't have an only and right solution to your problem.

Pavel Shved
Thanks Pavel. My feeling was that the fully optimal solution would be intractable, but that it should be possible to make some reasonable optimizations in a bounded time period.SMTs look interesting, thanks for pointing them out, but I'm having trouble understanding this sentence from your answer: "Then they can, for instance, reason if (yes, two equal conjunctions) whether one predicate implies another is a tautology", can you please clarify?
Bill
@Bill: Clarifying. In your example, you were to discard predicate `A > 1` because it was implied by `A > 0`. I.e. in all cases where `A>1` is true, `A>0` is true too (that's called "implication"). Given your SMT solver has the formal arithmetic axioms uploaded, it can reason that the formula `( A > 0 ) implies ( A > 1)` is a tautology. After this reasoning you can withdraw `A>0` from your expression. But that's just one out of many applications of SMT solvers and I outlined it out just because you used it in your question.
Pavel Shved
Okay, that makes sense, thanks Pavel.
Bill