Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to simplify some simple expressions (eg. (0)&~((1)|(0)) ) #82

Open
gabe-nasc opened this issue Aug 16, 2018 · 1 comment
Open

Comments

@gabe-nasc
Copy link

I've ran into a problem while using simplify with a few expressions, even though they are valid and have not apparent reason to cause these errors.

One thing I noticed is that if I remove the 'not' symbol from them, they'll work "correctly"

Cases where "TypeError: '_FALSE' object is not callable" is raised:

(0)&~((1)|(0))
(1)&(~((0)|(1)))
(0)&(~((0)|(0)))&(1)

Cases where "TypeError: '_TRUE' object is not callable" is raised:

(~((0)&(0)))&(1)&(0)&(1)
(0)|(0)|(~((1)&(0)&(0)&(0)&(0)))
(~((1)&(0)&(1)&(1)))|(0)|(~((0)|(0)|(1)))

@MarcelRobitaille
Copy link

I have reproduced this same issue. The minimal expression that causes this issue is 'NOT (FALSE)'. The problem is here. The self.TRUE and self.FALSE instances of DualBase are given instances not classes of _TRUE and _FALSE. I have come up with the following workaround:

algebra = boolean.BooleanAlgebra()
algebra.TRUE.dual = type(algebra.FALSE)
algebra.FALSE.dual = type(algebra.TRUE)

A more permanent solution would be to change the __init__ method of BooleanAlgebra like so:

self.TRUE_class = TRUE_class or _TRUE
self.TRUE = self.TRUE_class()

self.FALSE_class = FALSE_class or _FALSE
self.FALSE = self.FALSE_class()

# they cross-reference each other
self.TRUE.dual = self.FALSE_class
self.FALSE.dual = self.TRUE_class

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants