重构布尔方程
假设您有一个布尔规则/表达式,如下所示
(A OR B) AND (D OR E) AND F
您希望将其转换为尽可能多的 AND only 表达式,例如
A AND D AND F
A AND E AND F
B AND D AND F
B AND E AND F
您只是减少 OR,使其变为
(A AND D AND F) OR (A AND E AND F) OR (...)
布尔代数中是否有一个属性可以做到这一点?
Let's say you have a Boolean rule/expression like so
(A OR B) AND (D OR E) AND F
You want to convert it into as many AND only expressions as possible, like so
A AND D AND F
A AND E AND F
B AND D AND F
B AND E AND F
You are just reducing the OR's so it becomes
(A AND D AND F) OR (A AND E AND F) OR (...)
Is there a property in Boolean algebra that would do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您的示例正在利用 AND 相对于 OR 的分布性,如此处所示。
您所需要做的就是依次应用它。 例如,使用
x*(y+z) = (x*y)+(x*z)
(其中 * 表示 AND,+ 表示 OR):Your example is exploiting the the distributivity of AND over OR, as shown here.
All you need to do is apply that successively. For example, using
x*(y+z) = (x*y)+(x*z)
(where * denotes AND and + denotes OR):您可能有兴趣阅读卡诺地图。 它们是简化布尔表达式的工具,但您也可以使用它们来确定所有单独的表达式。 我不确定你如何将其概括为你可以为其编写程序的算法。
You may be interested in reading about Karnaugh maps. They are a tool for simplifying boolean expressions, but you could use them to determine all of the individual expressions as well. I'm not sure how you might generalize this into an algorithm you could write a program for though.
您可能对合取范式或其兄弟析取范式。
You might be interested in Conjunctive Normal form or its brother, Disjunctive normal form.
据我所知,布尔代数不能仅通过 AND 和 OR 运算来构建。
如果只有这两个运算,则无法接收 NOT 运算。
您可以将任何表达式转换为全套布尔运算。
这是一些完整的集合:
As far as I know boolean algebra can not be build only with AND and OR operations.
If you have only this two operation you are not able to receive NOT operation.
You can convert any expression to the full set of boolean operations.
Here is some full sets:
假设您可以使用 NOT 运算,则可以仅使用 AND 或仅使用 OR 重写任何布尔表达式。 在你的情况下:
我倾向于使用上面的工程速记并写:
所以:
算术推论实际上对于因式分解非常有用。
通过 德摩根定律:
因此您可以将表达式重写为:
Assuming you can use the NOT operation, you can rewrite any Boolean expression with only ANDs or only ORs. In your case:
I tend to use engineering shorthand for the above and write:
So:
The corollary to arithmetic is actually quite useful for factoring terms.
By De Morgan's Law:
So you can rewrite your expression as:
看看德摩根定理。 该链接指向与电子门相关的文档,但理论保持不变。
它表示,如果我们
(引用上述链接文件)
Take a look at DeMorgan's theorem. The link points to a document relating to electronic gates, but the theory remains the same.
It says that any logical binary expression remains unchanged if we
(quoting from the above linked document)