寻找一个好的布尔代数库
我正在编写一个处理一些布尔代数的工具。它基本上是一个基于用户定义的文件创建状态机的工具,其中包含状态名称、条件和转换信息。发生状态转换的方法基本上是查看布尔逻辑表。例如,从 State1 到 State2 的转换,如果:
(A & B) | (C & ~D) | (E)
我已经实现了这一切,但现在我需要添加做一些有趣的事情的能力,例如反转整个 shebang:
~((A & B) | (C & ~D) | (E)) = (via DeMorgan) (~A & ~C & ~E) | (~A & D & ~E) | (~B & ~C & ~E) | (~B & D & ~E)
结果必须位于 析取范式。
基本上,我不想自己写这个,我希望某个地方有一个图书馆知道如何处理这样的事情。我遇到过 SymPy,但我不确定是否有布尔代数模块。
我的应用程序是用 C 编写的(可能不应该是),但任何东西都会有帮助。
I'm writing a tool that deals with some boolean algebra. It's basically a tool to create a state machine based on a user-defined file that contains state names, conditions, and transition information. The method by which state transitions occur is to basically look at a boolean logic table. e.g. transition from State1 to State2 if:
(A & B) | (C & ~D) | (E)
I've got this all implemented, but now I need to add the ability to do some fun stuff like inverting the whole shebang:
~((A & B) | (C & ~D) | (E)) = (via DeMorgan) (~A & ~C & ~E) | (~A & D & ~E) | (~B & ~C & ~E) | (~B & D & ~E)
The result must be in Disjunctive Normal Form.
Basically, I don't want to write this myself and I'm hoping there's a library somewhere that knows how to deal with stuff like this. I've come across SymPy, but I'm not sure if there is a boolean algebra module.
My app is written in C (probably shouldn't be), but anything will help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我没有合并代码,而是发现了一些免费供任何使用的优秀应用程序(通过加利福尼亚大学)。一个名为 Logic Friday 的工具对其他一些应用程序有一个很好的前端:misii 和 espresso(包含在安装),执行符号布尔代数。
没有很好的命令行界面,但您可以传递文件来完成这项工作。这执行了我正在寻找的最小化。
Rather than incorporate code, I found a few great applications that are free for any use (via the University of California). A tool called Logic Friday has a nice front end to a few other applications: misii and espresso (included in the install), that perform symbolic Boolean algebra.
There isn't a great command line interface, but you can pass files around to do the job. This performs the minimization I was looking for.
您可以尝试这个开源项目,尽管它不是一个库,您只需将 布尔代数类 复制到添加到您的项目
You can try out this open source project, although its not a library you can just copy the Boolean Algebra Class to add to your project