Code for function generation and a problem

21 views
Skip to first unread message

Sachin Joglekar

unread,
Sep 19, 2012, 4:21:28 AM9/19/12
to sy...@googlegroups.com

I have attached a file containing the code I have written for Boolean function generation using Q-M method in python. I would like to incorporate SymPy into its working. I would like suggestions if its possible . One problem I am facing is dis..

>>>from sympy import *
>>>from sympy.abc import *
>>>b=Not(B)
>>>b
Not(B)
>>>B=True
>>>Not(B)
False
>>>b
Not(B)

Is there any way we could tweak the Not function so that b gets recognised as being dependant on B and change its value accordingly?
minterms - Copy.py

Chris Smith

unread,
Sep 19, 2012, 5:09:27 AM9/19/12
to sy...@googlegroups.com
>>>>from sympy import *
>>>>from sympy.abc import *
>>>>b=Not(B)
>>>>b
> Not(B)
>>>>B=True
>>>>Not(B)
> False
>>>>b
> Not(B)

Try replacing B in place with subs:

> b = Not(B)
> b.subs(B, True)
False
> b.subs(B, False)
True

/c

Aaron Meurer

unread,
Sep 19, 2012, 10:55:51 AM9/19/12
to sy...@googlegroups.com
This is just the way things work in Python. See
http://docs.sympy.org/dev/gotchas.html#variables-assignment-does-not-create-a-relation-between-expressions.

Aaron Meurer
> --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/sympy/-/bGAl0mphr34J.
> To post to this group, send email to sy...@googlegroups.com.
> To unsubscribe from this group, send email to
> sympy+un...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/sympy?hl=en.

Sachin Joglekar

unread,
Sep 19, 2012, 1:04:15 PM9/19/12
to sy...@googlegroups.com
Ok. Then I guess I will have to create a separate function for evaluation of boolean functions generated by the module.
Reply all
Reply to author
Forward
0 new messages