Looking at the implementation of Xor, Nand, Nor, and Not classes, it appears that the aim is to maintain formulas in negation normal form ( http://en.wikipedia.org/wiki/Negation_normal_form ). This would imply (excuse the pun ;)) that the Implies class should do the same.
On Fri, Mar 19, 2010 at 4:52 PM, Vinzent Steinberg < vinzent.steinb...@googlemail.com> wrote: > What is the motivation of this? It would be nice if you could add this > to the commit message. > 'Implies(x, y)' is clearly less readable than 'Or(Not(x), y)', imho. > > Fabian, what is your opinion about this? > > Vinzent > > 2010/3/17 Christian Muise <christian.mu...@gmail.com>: > > --- > > doc/src/modules/logic.txt | 7 ++++--- > > sympy/logic/boolalg.py | 12 +++++++++++- > > sympy/logic/tests/test_boolalg.py | 6 ++++-- > > 3 files changed, 19 insertions(+), 6 deletions(-) > > > > diff --git a/doc/src/modules/logic.txt b/doc/src/modules/logic.txt > > index 2487d57..e466d5a 100644 > > --- a/doc/src/modules/logic.txt > > +++ b/doc/src/modules/logic.txt > > @@ -24,12 +24,13 @@ You can build boolean expressions with the standard > python operators & (And), > > >>> ~x > > Not(x) > > > > -You can also form implications with >>, <<, and class Equivalent: > > +You can also form implications with >>, <<, and class Equivalent, which > are > > +compiled away into their logical equivalents: > > > > >>> x >> y > > - Implies(x, y) > > + Or(Not(x), y) > > >>> x << y > > - Implies(y, x) > > + Or(Not(y), x) > > > > Like most types in SymPy, Boolean expressions inherit from > sympy.core.Basic: > > > > diff --git a/sympy/logic/boolalg.py b/sympy/logic/boolalg.py > > index cd979bd..0a45e42 100755 > > --- a/sympy/logic/boolalg.py > > +++ b/sympy/logic/boolalg.py > > @@ -104,7 +104,17 @@ def eval(cls, *args): > > return A > > > > class Implies(BooleanFunction): > > - pass > > + """Logical implication. > > + A implies B is equivalent to !A v B > > + """ > > + @classmethod > > + def eval(cls, *args): > > + if len(args) < 2: > > + raise ValueError, "Only %d operand(s) used for an Implies > (pairs are required): %s" % (len(args), str(args)) > > + elif len(args) > 2: > > + return map(cls, args) > > + else: > > + return Or(Not(args[0]), args[1]) > > > > class Equivalent(BooleanFunction): > > """Equivalence relation. > > diff --git a/sympy/logic/tests/test_boolalg.py > b/sympy/logic/tests/test_boolalg.py > > index 3102f06..e28f063 100755 > > --- a/sympy/logic/tests/test_boolalg.py > > +++ b/sympy/logic/tests/test_boolalg.py > > @@ -97,8 +97,10 @@ def test_Nor(): > > > > def test_Implies(): > > A, B, C = symbols('ABC') > > - Implies(True, True) == True > > - Implies(False, False) == False > > + assert Implies(True, True) == True > > + assert Implies(True, False) == False > > + assert Implies(False, True) == True > > + assert Implies(False, False) == True > > assert A >> B == B << A > > > > def test_Equivalent(): > > -- > > 1.6.3.3 > > -- > You received this message because you are subscribed to the Google Groups > "sympy-patches" group. > To post to this group, send email to sympy-patc...@googlegroups.com. > To unsubscribe from this group, send email to > sympy-patches+unsubscr...@googlegroups.com<sympy-patches%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/sympy-patches?hl=en. > > -- You received this message because you are subscribed to the Google Groups "sympy-patches" group. To post to this group, send email to sympy-patc...@googlegroups.com. To unsubscribe from this group, send email to sympy-patches+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy-patches?hl=en.