Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: ((a&&b)||c)==((a||c)&&(b||c))

  • To: mathgroup at smc.vnet.net
  • Subject: [mg62069] Re: [mg62015] ((a&&b)||c)==((a||c)&&(b||c))
  • From: "Steven T. Hatton" <hattons at globalsymmetry.com>
  • Date: Thu, 10 Nov 2005 02:51:25 -0500 (EST)
  • References: <200511090845.DAA17387@smc.vnet.net> <43721D94.9050307@wolfram.com>
  • Sender: owner-wri-mathgroup at wolfram.com

[NOTE: I BCCed Jason on this, not to keep it a secret, but because I didn't 
want to volunteer his address to the spam harvesters.]

On Wednesday 09 November 2005 11:02 am, Daniel Lichtblau wrote:
> Steven T. Hatton wrote:
> > Why does Mathematica not determine that the following is true?
> >
> > ((a \[And] b) \[Or] c) == ((a \[Or] c) \[And] (b \[Or] c))
> >
> > This little function shows that the lhs  and rhs have the same truth
> > tables, and are therefore equivalent:
> >
> > TruthTable[s_, argc_] := Module[
> >     {tt = Tuples[{True, False}, argc]},
> >     {#, s @@ #} & /@ tt // TableForm
> >     ]
>
> Equal does not do logical manipulations on its operands. 

That's part of what I'm trying to understand. Mathamatica AFAIK takes 
expressions and transforms them into the simplest form possible, and then 
does pattern patching.  I suspect that it's not really "Equal" per se, that 
does not do logical manipulations, but Mathematica in general.  The rules for 
manipulating logical expressions are not amenable to the precedence hierarchy 
found in the arithmetic of real numbers.  That is * distributes over +, but + 
does not distribute over *; OTOH && distributes over ||, _and_ || distributes 
over &&.

> Nor will 
> LogicalExpand automatically thread over Equal. Probably a better way to
> implement your biconditional (mentioned in another MathGroup post today,
> with regard to this same example) would be
>
> biconditional[p_, q_] := Implies[p,q] && Implies[q,p]
> (suggested by Andrzej Kozlowski, I think)
>
> or
>
> biconditional[p_, q_] := Not[Xor[p,q]]
>
> or logical expand in advance and use
>
> biconditional[p_, q_] := (p&&q) || (!p&&!q)
>
> These remain in the realm of logical operations rather than
> "arithmetic-like" operators such as Equal. Depending on your purpose
> this might be preferable. The fact that you use a truth table above
> indicates to me that you probably would be better served by strictly
> logical operations.

I believe I will, in the end, use Implies, as Andrzej suggested, but I haven't 
solved another part of the problem which seems more fundamental.  I need a 
way to persuade a binary operator to bind more loosely than the logical 
operators.  I just realized I could probably use the precedence of Implies as 
the SyntaxForm argument, if I could get that to work.  

To your knowledge, does that feature of the Utilities`Notation` package work?  
The documentation discussing SyntaxForm seems to have some lacunae.  Perhaps 
I'm just not reading closely enough.

This is an example of what I've attempted:

In[2]:=
<<Utilities`Notation`

In[3]:=
InfixNotation[\[DoubleLeftRightArrow],Biconditional,
  SyntaxForm\[Rule] "\[Implies]"]

In[4]:=
(a\[And]b)\[Or]c\[DoubleLeftRightArrow](a\[Or]c)\[And](b\[Or]c)

Out[4]=
(a&&b)||(c\[DoubleLeftRightArrow](a||c)&&(b||c))

In[5]:=
%//FullForm

Out[5]//FullForm=
Or[And[a,b],And[Biconditional[c,Or[a,c]],Or[b,c]]]


Perhaps there is some way to use the TagBox[__,SyntaxForm->"=>"] explicitly?

Steven


  • Prev by Date: Re: 'Good' or 'Proper' Mathematica coding habits question
  • Next by Date: Re: Re: integer solution
  • Previous by thread: Re: ((a&&b)||c)==((a||c)&&(b||c))
  • Next by thread: Re: ((a&&b)||c)==((a||c)&&(b||c)) is not true