带范围谓词的析取范式
我需要一个库/算法,可以将包含范围谓词的任意逻辑表达式转换为简化的不相交范式。
例子 : (x>40)& ((x>50)|(y>10))→ (x>50)| (x>40)& (y > 10)
基本上,我想要简单地这样一个表达式,以便尽可能快地进行评估。
有人可以帮助我吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Wolfram Alpha 可以很好地处理您的表达式:
参见此处。
...这意味着 Mathematica 开箱即用,适合执行此操作。但是,您可能不想使用那么大的程序来解决这样一个相对简单的问题。
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.
像 ANTLR 这样的工具将帮助您为表达式构建解析树。然后,您可以根据运算符的交换属性“展平”树。我个人不知道有什么算法或库可以做到这一点。
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.