Status: Valid
Owner: ----
Labels: Type-Defect Priority-Medium Logic

New issue 3499 by [email protected]: bool_equal doesn't handle expressions with Dummy well
http://code.google.com/p/sympy/issues/detail?id=3499

Dummy symbols created with no name default to having a name that is a number. Dummies don't round-trip through S(Dummy('x').name), however, for two reasons: a Symbol rather than a Dummy is created and if 'x' is replaced with '' then an integer is returned instead. This 2nd problem then causes bool_equal to fail:

..>>> bool_equal(And(a,~Dummy()),And(b),1,1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "sympy/logic/boolalg.py", line 879, in bool_equal
    function1 = simplify_logic(function1)
  File "sympy/logic/boolalg.py", line 843, in simplify_logic
    return POSform(string_variables, truthtable)
  File "sympy/logic/boolalg.py", line 802, in POSform
    return sympify(string)
  File "sympy/core/sympify.py", line 180, in sympify
    expr = parse_expr(a, locals or {}, rational, convert_xor)
  File "sympy/parsing/sympy_parser.py", line 174, in parse_expr
    code, global_dict, local_dict)  # take local objects in preference
  File "<string>", line 1, in <module>
TypeError: bad operand type for unary ~: 'Integer'

[noonker@oldtea sympy{* (no branch)}]$ python
Python 2.7.3 (default, Aug  1 2012, 05:16:07)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
bool_equal(And(a,~Dummy()),And(b))
False

The quick solution is to use str(variable) rather than variable.name, but a better solution would be to have the Dummy name be `_123` rather than `123` (where 123 is the current `Dummy._index`. But then string printing should probably be fixed so it doesn't print with a double `__` before the number (though that is less important).

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to