Darren's Weekly Nugget 07/10/2006

Darren's Weekly Nugget 07/10/2006

Post by Darre » Wed, 12 Jul 2006 02:10:12


Have you ever used the Implies function?  It's on the Boolean palette:
<img src=" http://www.yqcomputer.com/ ">
Every once in a while I'm writing conditional code that needs to execute as follows:  If X is True and Y is False, do something.  For all other cases, do something else.  When I'm writing this kind of code, I always reach for Implies.  When I see it on my diagram, it's always immediately clear to me what's going on...which is good, since Boolean logic was never my strong suit.
-D P.S. - Check out past nuggets <a href=" http://www.yqcomputer.com/ ;message.id=1669" target="_blank"> here</a>. Message Edited by Darren on 07-10-2006 11:54 AM


Implies.jpg:
http://www.yqcomputer.com/
 
 
 

Darren's Weekly Nugget 07/10/2006

Post by agil » Wed, 12 Jul 2006 02:40:10

In formal notation, we often use the arrow for an if, then statement.  This is the exact same thing except in boolean form.
 
if X, then Y 
translates to 
~X v Y  (not X or Y) 
or, X =>Y
or X implies Y
 
Drawing the truth table shows this:
X | Y | Result
----------------
1 | 1 | 1 
1 | 0 | 0 
0 | 1 | 1 
0 | 0 | 1
 
 
Or in other words, X is a sufficient condition for Y (but not necessary).
 
I onced wondered, does labview have the the double arrow (IFF)? X<=>Y?
 
which means IFF X then Y
 or 
X is a necessary condition for Y.
 
Then I realized: Heh, stupid question, as the boolean function is simply just X. by itself :)

 
 
 

Darren's Weekly Nugget 07/10/2006

Post by altenbac » Wed, 12 Jul 2006 03:10:12

Yes, implies is proably a bit underused, but I have used it in the past, (e.g. "current boolean to X, previous state from shift register to y" senses a False->True transition but not a True-> False transition).
 
As tst mentioned, the functionality can be easily duplicated by a compound node, which might look a bit more familiar to some of us. :D
 
<img src=" http://www.yqcomputer.com/ ">
 Message Edited by altenbach on 07-10-2006 10:58 AM


implies.png:
http://www.yqcomputer.com/
 
 
 

Darren's Weekly Nugget 07/10/2006

Post by Darre » Wed, 12 Jul 2006 04:10:09

Yup, but when I see Implies on the diagram, it's immediately clear to me that "oh, here's a situation where I'm looking for a specific T/F combination of these two Booleans."  That's not as clear to me if I see a Compound Arithmetic set to Or with one of the inputs negated.  :)
Of course, I'm no computer scientist...perhaps the latter is more understandable by those hooligans.  ;)
-D
 
 
 

Darren's Weekly Nugget 07/10/2006

Post by altenbac » Thu, 13 Jul 2006 01:10:13


.., but I've known quite a number of people who just can't seem to grok it. 



I have to admit that every time I used "implies" so far, I had to do a double-take on the context help to make sure I don't mix up the x and y inputs, since they are not interchangeable. :o
(Of course we can just blindly hook it up, then use the switcheroo trick from an earlier nugget to swap away until the results are as expected ;)).
Using the compound node, you can have the inverted input on the top or bottom, and it is always clear what's what. :DMessage Edited by altenbach on 07-11-2006 08:56 AM
 
 
 

Darren's Weekly Nugget 07/10/2006

Post by Travis M » Thu, 13 Jul 2006 04:40:08

It?s also important to note that in the above description
(Darren?s at the very top) when you want the code to ?do something? when you
have X but not Y you?ll need to do that ?something? in the FALSE case of a case
structure and not the TRUE case of that structure if you wire it directly (this
could be a small point of confusion)?.



 



To comment on the IFF operator, the <a href=" http://www.yqcomputer.com/ %7Eramsey/Logic/Iff.html" target="_blank">truth table</a> depends on
both X and Y, so the function for x <=> y is not equivalent to
x.  As far as why it?s not implemented in
LabVIEW, I suppose its just not used all that often ;).



 



As much ?fun? as logic class was in college, I wouldn?t exactly
say I use it all the time (ask me what Demorgan?s theorem is for example and
watch me scratch my head in forgetfulness).



 



Have a great week everybody,
 
 
 

Darren's Weekly Nugget 07/10/2006

Post by tbob » Thu, 13 Jul 2006 05:10:06


ask me what Demorgan?s theorem is for example and watch me scratch my head in forgetfulness).

 

OK, what is Demorgan's theorem?
 
 
 

Darren's Weekly Nugget 07/10/2006

Post by agil » Thu, 13 Jul 2006 05:40:13


To comment on the IFF operator, the <a href=" http://www.yqcomputer.com/ %7Eramsey/Logic/Iff.html" target="_blank">truth table</a> depends on both X and Y, so the function for x <=> y is not equivalent to x.  As far as why it?s not implemented in LabVIEW, I suppose its just not used all that often ;).

 



Yeah, I made that mistake.  Isn't it just an nxor (exclusive-or negated)?  So I guess it is implemented in LV under "not exclusive or".