Skip to content

Simpler formula produced after second simplification round #110

Open
@tomas789

Description

@tomas789

In my sample code I have a formula which after call to .simplify() produces a correct formula. When calling .simplify() second times we get an even simpler result. This might be considered for future improvements.

Also note that the formula given is not a minimal example.

import boolean

algebra = boolean.BooleanAlgebra()
TRUE, FALSE, NOT, AND, OR, symbol = algebra.definition()

x = algebra.parse("""
(~((~((0)|x3|(1)))&((x8&x8)|(x0|(0)|x2|x0|x6))&(x2&((1)&(0)&x5)&(1))&(~(x3|x7|x1|x10|(0)))&(1)))&(~((x6&(x4&x2)&~x7&~x9&(x3|(0)))&((x6&x9&x8)|x7)))&((~(~x10|~x7|x2|~x8))|(~(~x5&~x10))|(~x4&x6&(~((1)|x8|(1)))&((x4|x8|x9|(1)|(0))|x7|(x7&x2))&(0))|((0)|((x2|(0))&(x2&x2&x9&x0)&(x6&x4&x3&(0))&(x6&x7&(0))&(x9|x0|(0)|(0)|x10))|(x6|(~(0))|(x6&(1)&x3&x0&(1)))))
""".strip())
x1 = x.simplify()
x2 = x1.simplify()
print(x)
print(x1)
print(x2)

The snippet produces following output

(~((~((0)|x3|(1)))&((x8&x8)|(x0|(0)|x2|x0|x6))&(x2&((1)&(0)&x5)&(1))&(~(x3|x7|x1|x10|(0)))&(1)))&(~((x6&(x4&x2)&~x7&~x9&(x3|(0)))&((x6&x9&x8)|x7)))&((~(~x10|~x7|x2|~x8))|(~(~x5&~x10))|(~x4&x6&(~((1)|x8|(1)))&((x4|x8|x9|(1)|(0))|x7|(x7&x2))&(0))|((0)|((x2|(0))&(x2&x2&x9&x0)&(x6&x4&x3&(0))&(x6&x7&(0))&(x9|x0|(0)|(0)|x10))|(x6|(~(0))|(x6&(1)&x3&x0&(1)))))
~x2|~x3|~x4|~x6|x7|x9|(~x6|~x8|~x9)
1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions