Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Can't Simplify logical expression

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90822] Re: Can't Simplify logical expression
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Fri, 25 Jul 2008 06:16:26 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <g69ftk$ig9$1@smc.vnet.net>

realyigo at gmail.com wrote:

> Simplify[(a && (! b)) || (b && (! a))]
> 
> I get this:
> a && ! b || b && ! a
> 
> But I want this:
> Xor[a,b]
> 
> 
> Any suggestions?

First, a couple of general remarks. Functions such as FullSimplify[] and 
LogicalExpand[] are more appropriate than Simplify[] when dealing with 
logical expressions. Also, it is better to use Implies[] rather than 
Equal[]. For instance,

     FullSimplify[(a && (! b)) || (b && (! a)) == Xor[a, b]]

     (a && ! b) || (b && ! a) == (a \[Xor] b)

     Implies[(a && (! b)) || (b && (! a)), Xor[a, b]] // FullSimplify

     True

     LogicalExpand[(a && (! b)) || (b && (! a))] ==
       LogicalExpand[ Xor[a, b]]

     True

Back to your original query, though Mathematica can easily go from Xor[] 
to its expanded form

     LogicalExpand[ Xor[a, b]]

     (a && ! b) || (b && ! a)

the reverse operation might be much more challenging for a variety of 
reasons.

The thread titled, "((a&&b)||c)==((a||c)&&(b||c))", (started on 
Wednesday, 9 Nov 2005), is a must read on this subject. If you do not 
want to read all the posts, at least be sure to read Daniel Lichtblau's 
reply about And, Or, and Not vs Xor at

http://groups.google.com/group/comp.soft-sys.math.mathematica/msg/714ea41389818a3f

Regards,
-- Jean-Marc



  • Prev by Date: Re: Function Programming Problems
  • Next by Date: Re: Function Programming Problems
  • Previous by thread: Re: Can't Simplify logical expression
  • Next by thread: A suggestion fo web-hosting of 3-D images