Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #91385 > unrolled thread

Logic problem: need better logic for desired thruth table.

Started by"Skybuck Flying" <skybuck2000@hotmail.com>
First post2015-05-28 23:50 +0200
Last post2015-05-29 19:07 -0400
Articles 20 on this page of 25 — 11 participants

Back to article view | Back to comp.lang.python


Contents

  Logic problem: need better logic for desired thruth table. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-05-28 23:50 +0200
    Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed) "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-05-28 23:55 +0200
      Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed) "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-05-29 00:07 +0200
        Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed) "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-05-29 00:08 +0200
          Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed) "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-05-29 00:12 +0200
            Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed) "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-05-29 04:45 +0200
              Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed) "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-05-29 04:56 +0200
          Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed) Grant Edwards <invalid@invalid.invalid> - 2015-05-28 22:13 +0000
            Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed) Grant Edwards <invalid@invalid.invalid> - 2015-05-28 22:15 +0000
    Re: Logic problem: need better logic for desired thruth table. sohcahtoa82@gmail.com - 2015-05-28 14:58 -0700
      Re: Logic problem: need better logic for desired thruth table. Michael Torrie <torriem@gmail.com> - 2015-05-28 16:16 -0600
        Re: Logic problem: need better logic for desired thruth table. Grant Edwards <invalid@invalid.invalid> - 2015-05-28 22:54 +0000
          Re: Logic problem: need better logic for desired thruth table. Grant Edwards <invalid@invalid.invalid> - 2015-05-28 23:03 +0000
            Re: Logic problem: need better logic for desired thruth table. Michael Torrie <torriem@gmail.com> - 2015-05-28 18:52 -0600
        Re: Logic problem: need better logic for desired thruth table. sohcahtoa82@gmail.com - 2015-05-28 17:15 -0700
      Re: Logic problem: need better logic for desired thruth table. Denis McMahon <denismfmcmahon@gmail.com> - 2015-05-28 23:25 +0000
        Re: Logic problem: need better logic for desired thruth table. "Skybuck Flying" <skybuck2000@hotmail.com> - 2015-05-29 04:46 +0200
    Re: Logic problem: need better logic for desired thruth table. Grant Edwards <invalid@invalid.invalid> - 2015-05-28 22:01 +0000
      Re: Logic problem: need better logic for desired thruth table. Grant Edwards <invalid@invalid.invalid> - 2015-05-28 22:11 +0000
    Re: Logic problem: need better logic for desired thruth table. Tim Chase <python.list@tim.thechases.com> - 2015-05-28 17:02 -0500
    Re: Logic problem: need better logic for desired thruth table. Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2015-05-29 01:13 +0300
    Re: Logic problem: need better logic for desired thruth table. Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-05-28 18:39 -0400
      Re: Logic problem: need better logic for desired thruth table. Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-05-28 23:56 +0100
    Re: Logic problem: need better logic for desired thruth table. Paul <nospam@needed.com> - 2015-05-28 19:21 -0400
    Re: Logic problem: need better logic for desired thruth table. M Philbrook <jamie_ka1lpa@charter.net> - 2015-05-29 19:07 -0400

Page 1 of 2  [1] 2  Next page →


#91385 — Logic problem: need better logic for desired thruth table.

From"Skybuck Flying" <skybuck2000@hotmail.com>
Date2015-05-28 23:50 +0200
SubjectLogic problem: need better logic for desired thruth table.
Message-ID<3794b$55678d83$5419aafe$56138@news.ziggo.nl>
Hello,

I was just coding and ran into a little logic problem which is as follows:

There are two booleans/variables which can be either false or true.

The desired thrutle table is:

A = input
B = input
C = output

A B C:
-------
F F T
F T F
T F T
T T T

Surpisingly enough I don't think there is a casual/common operator for this 
thruth table.

AND does not apply.
OR does not apply.
XOR does not apply.

So I would need some combined operators to give the desired result.

I tried logic below... but funny enough it failed, now I feel like a noob 
lol and share this funny little fail logic with you.

Can you improve/fix the logic ?

This is python code, but this^ logic/thruth table problem basically applies 
to any programming language:

# loop has to run if:
# while DesiredResult==True:
# Desired truth table for BotWaitForCooldown and CooldownDetected
# BotWaitForCooldown:  CooldownDetected: Desired Result:
# False       False    True
# False       True     False
# True     False    True
# True     True     True
# desired/suiting logic:
# (BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected))

def TestLogic( BotWaitForCooldown, CooldownDetected ):
return BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected) 
# this logic is flawed, please improve logic.

if TestLogic( False, False ) == True:
print "test 1 ok"
else:
print "test 1 failed"

if TestLogic( False, True ) == False:
print "test 2 ok"
else:
print "test 2 failed"

if TestLogic( True, False ) == True:
print "test 3 ok"
else:
print "test 3 failed"

if TestLogic( True, True ) == True:
print "test 4 ok"
else:
print "test 4 failed"

Bye,
  Skybuck. 

[toc] | [next] | [standalone]


#91386 — Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)

From"Skybuck Flying" <skybuck2000@hotmail.com>
Date2015-05-28 23:55 +0200
SubjectRe: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)
Message-ID<2ac80$55678eb8$5419aafe$56778@news.ziggo.nl>
In reply to#91385
I think I have run into this problem before... but solved it with some 
seperate if statements.

However in this case/this time I would like to not solve it with if 
statements, but simply and/or/not/xor, in other words, boolean operators.

So what would help is a "thruth table to logic" convertor/generator ?!

Anybody know one that is suited for boolean logic/software 
programming/programming languages/boolean operations ?

Bye,
  Skybuck.

Original posting:

"Skybuck Flying"  wrote in message 
news:3794b$55678d83$5419aafe$56138@news.ziggo.nl...

Hello,

I was just coding and ran into a little logic problem which is as follows:

There are two booleans/variables which can be either false or true.

The desired thrutle table is:

A = input
B = input
C = output

A B C:
-------
F F T
F T F
T F T
T T T

Surpisingly enough I don't think there is a casual/common operator for this
thruth table.

AND does not apply.
OR does not apply.
XOR does not apply.

So I would need some combined operators to give the desired result.

I tried logic below... but funny enough it failed, now I feel like a noob
lol and share this funny little fail logic with you.

Can you improve/fix the logic ?

This is python code, but this^ logic/thruth table problem basically applies
to any programming language:

# loop has to run if:
# while DesiredResult==True:
# Desired truth table for BotWaitForCooldown and CooldownDetected
# BotWaitForCooldown:  CooldownDetected: Desired Result:
# False       False    True
# False       True     False
# True     False    True
# True     True     True
# desired/suiting logic:
# (BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected))

def TestLogic( BotWaitForCooldown, CooldownDetected ):
return BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected)
# this logic is flawed, please improve logic.

if TestLogic( False, False ) == True:
print "test 1 ok"
else:
print "test 1 failed"

if TestLogic( False, True ) == False:
print "test 2 ok"
else:
print "test 2 failed"

if TestLogic( True, False ) == True:
print "test 3 ok"
else:
print "test 3 failed"

if TestLogic( True, True ) == True:
print "test 4 ok"
else:
print "test 4 failed"

Bye,
  Skybuck.

[toc] | [prev] | [next] | [standalone]


#91392 — Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)

From"Skybuck Flying" <skybuck2000@hotmail.com>
Date2015-05-29 00:07 +0200
SubjectRe: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)
Message-ID<c8624$556791a3$5419aafe$58453@news.ziggo.nl>
In reply to#91386
This is a start lol:

https://www.youtube.com/watch?v=lKqTSBKmWA4

I wonder if it can be simplied... I'll give it a try.

Basically it comes down to creating a logic expression for each true result 
in the desired output and or-ing with each other.

The variables leading to the true result in the desired output need to be 
kept if true, and negated if false.

So for example:
A B C
F T T

((NOT A) AND (B) AND ETC) OR ETC.

What the video didn't really explain is probably to "and" the variables... 
but it did mention "multiply".

I guess "AND" is the closest thing to a multiply ;)

Makes sense... only AND gives a 1 output if all variables are true, 
otherwise it would zero out...

Bye,
  Skybuck. 

[toc] | [prev] | [next] | [standalone]


#91393 — Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)

From"Skybuck Flying" <skybuck2000@hotmail.com>
Date2015-05-29 00:08 +0200
SubjectRe: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)
Message-ID<c48b1$556791ee$5419aafe$58588@news.ziggo.nl>
In reply to#91392
However I can already see I am not happy with this video solution.

I have 3 true outputs, and only 1 false output.

That would require a lot of logic.

I guess I can turn it around and negate the whole thing... and focus on the 
false output.

Bye,
  Skybuck. 

[toc] | [prev] | [next] | [standalone]


#91395 — Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)

From"Skybuck Flying" <skybuck2000@hotmail.com>
Date2015-05-29 00:12 +0200
SubjectRe: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)
Message-ID<7b1ef$556792ab$5419aafe$58931@news.ziggo.nl>
In reply to#91393
Ok, problem solved for now, it seems:

I used video tutorial method and inverted it for the false case ;)

But anyway... I would not only need a "thruth table to logic/boolean 
operations converter" but also a "boolean operations optimizer" ;)

# loop has to run if:
# while DesiredResult==True:
# Desired truth table for BotWaitForCooldown and CooldownDetected
# BotWaitForCooldown:  CooldownDetected: Desired Result:
# False       False    True
# False       True     False
# True     False    True
# True     True     True
# desired/suiting logic:
# (BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected))



def TestLogic( BotWaitForCooldown, CooldownDetected ):
# return BotWaitForCooldown or ((not BotWaitForCooldown) and 
CooldownDetected) # this logic is flawed, please improve logic.
return (not ((not BotWaitForCooldown) and CooldownDetected))  # fixes it.

if TestLogic( False, False ) == True:
print "test 1 ok"
else:
print "test 1 failed"

if TestLogic( False, True ) == False:
print "test 2 ok"
else:
print "test 2 failed"

if TestLogic( True, False ) == True:
print "test 3 ok"
else:
print "test 3 failed"

if TestLogic( True, True ) == True:
print "test 4 ok"
else:
print "test 4 failed"

Bye,
  Skybuck. 

[toc] | [prev] | [next] | [standalone]


#91418 — Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)

From"Skybuck Flying" <skybuck2000@hotmail.com>
Date2015-05-29 04:45 +0200
SubjectRe: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)
Message-ID<dee1f$5567d2a8$5419aafe$38671@news.ziggo.nl>
In reply to#91395
Interestingly enough the shortest I have seen so far is ***:

def TestLogic( BotWaitForCooldown, CooldownDetected ):

# return BotWaitForCooldown or ((not BotWaitForCooldown) and 
CooldownDetected) # this logic is flawed, please improve logic.
# return (not ((not BotWaitForCooldown) and CooldownDetected)) # fixes it.
# return  (BotWaitForCooldown or (not CooldownDetected)) # optimization but 
looks weird :)
return (BotWaitForCooldown >= CooldownDetected) # *** even shorter, wow 
cool, thanks to Jussi Piitulainen

Apperently there is a short-coming/flaw in the reasoning about boolean 
logic, if boolean logic is converted to numbers/0/1 and comparisions allowed 
then apperently there are even shorter forms ?!? Am I correct ? Or am I 
missing something ? Perhaps branching don't count ? Hmmmm..... Is this 
branching ? Or something else... hmmm.... I think the comparison result 
could be used without requiring branching... so I think my conclusion might 
be correct.

Bye,
  Skybuck.

"Skybuck Flying"  wrote in message 
news:7b1ef$556792ab$5419aafe$58931@news.ziggo.nl...

Ok, problem solved for now, it seems:

I used video tutorial method and inverted it for the false case ;)

But anyway... I would not only need a "thruth table to logic/boolean
operations converter" but also a "boolean operations optimizer" ;)

# loop has to run if:
# while DesiredResult==True:
# Desired truth table for BotWaitForCooldown and CooldownDetected
# BotWaitForCooldown:  CooldownDetected: Desired Result:
# False       False    True
# False       True     False
# True     False    True
# True     True     True
# desired/suiting logic:
# (BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected))



def TestLogic( BotWaitForCooldown, CooldownDetected ):
# return BotWaitForCooldown or ((not BotWaitForCooldown) and
CooldownDetected) # this logic is flawed, please improve logic.
return (not ((not BotWaitForCooldown) and CooldownDetected))  # fixes it.

if TestLogic( False, False ) == True:
print "test 1 ok"
else:
print "test 1 failed"

if TestLogic( False, True ) == False:
print "test 2 ok"
else:
print "test 2 failed"

if TestLogic( True, False ) == True:
print "test 3 ok"
else:
print "test 3 failed"

if TestLogic( True, True ) == True:
print "test 4 ok"
else:
print "test 4 failed"

Bye,
  Skybuck.

[toc] | [prev] | [next] | [standalone]


#91420 — Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)

From"Skybuck Flying" <skybuck2000@hotmail.com>
Date2015-05-29 04:56 +0200
SubjectRe: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)
Message-ID<a7145$5567d542$5419aafe$43256@news.ziggo.nl>
In reply to#91418
I am not so sure anymore about my conclusion, I will investigate this 
further tomorrow.

It seems safe to conclude that at least the following operators have their 
own thruth tables:

=
<>
>
<
>=
<=

These are the comparision operators.

Assume True is greater than False allows them to be used as well.

The question that remains is:

How many "gates" or "basic" operations or "wires" would they require.

Are some of these perhaps very "efficient" and could thus lead to even 
shorter gate designs ?

However for my purposes, reducing code, the answer is already: YES

For software logic/boolean reduction the answer is already YES, funny and 
interestingly enough ! ;) :)

Bye,
  Skybuck.


[toc] | [prev] | [next] | [standalone]


#91397 — Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)

FromGrant Edwards <invalid@invalid.invalid>
Date2015-05-28 22:13 +0000
SubjectRe: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)
Message-ID<mk83tk$2qq$4@reader1.panix.com>
In reply to#91393
On 2015-05-28, Skybuck Flying <skybuck2000@hotmail.com> wrote:

> However I can already see I am not happy with this video solution.
>
> I have 3 true outputs, and only 1 false output.
>
> That would require a lot of logic.
>
> I guess I can turn it around and negate the whole thing... and focus on the 
> false output.

Don't they teach Karnaugh mapping any more?

http://en.wikipedia.org/wiki/Karnaugh_map

-- 
Grant Edwards               grant.b.edwards        Yow! I want the presidency
                                  at               so bad I can already taste
                              gmail.com            the hors d'oeuvres.

[toc] | [prev] | [next] | [standalone]


#91398 — Re: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)

FromGrant Edwards <invalid@invalid.invalid>
Date2015-05-28 22:15 +0000
SubjectRe: Logic problem: need better logic for desired thruth table. (thruth table to logic/boolean operations generator sought/needed)
Message-ID<mk841i$2qq$5@reader1.panix.com>
In reply to#91397
On 2015-05-28, Grant Edwards <invalid@invalid.invalid> wrote:
> On 2015-05-28, Skybuck Flying <skybuck2000@hotmail.com> wrote:
>
>> However I can already see I am not happy with this video solution.
>>
>> I have 3 true outputs, and only 1 false output.
>>
>> That would require a lot of logic.
>>
>> I guess I can turn it around and negate the whole thing... and focus on the 
>> false output.
>
> Don't they teach Karnaugh mapping any more?
>
> http://en.wikipedia.org/wiki/Karnaugh_map

BTW, your example truth table is shown in the paragraph '2-variable
map examples'

-- 
Grant Edwards               grant.b.edwards        Yow! Oh my GOD -- the
                                  at               SUN just fell into YANKEE
                              gmail.com            STADIUM!!

[toc] | [prev] | [next] | [standalone]


#91387

Fromsohcahtoa82@gmail.com
Date2015-05-28 14:58 -0700
Message-ID<67de616e-5af7-417d-88a9-db1c665df473@googlegroups.com>
In reply to#91385
On Thursday, May 28, 2015 at 2:50:18 PM UTC-7, Skybuck Flying wrote:
> Hello,
> 
> I was just coding and ran into a little logic problem which is as follows:
> 
> There are two booleans/variables which can be either false or true.
> 
> The desired thrutle table is:
> 
> A = input
> B = input
> C = output
> 
> A B C:
> -------
> F F T
> F T F
> T F T
> T T T
> 
> Surpisingly enough I don't think there is a casual/common operator for this 
> thruth table.
> 
> AND does not apply.
> OR does not apply.
> XOR does not apply.
> 
> So I would need some combined operators to give the desired result.
> 
> I tried logic below... but funny enough it failed, now I feel like a noob 
> lol and share this funny little fail logic with you.
> 
> Can you improve/fix the logic ?
> 
> This is python code, but this^ logic/thruth table problem basically applies 
> to any programming language:
> 
> # loop has to run if:
> # while DesiredResult==True:
> # Desired truth table for BotWaitForCooldown and CooldownDetected
> # BotWaitForCooldown:  CooldownDetected: Desired Result:
> # False       False    True
> # False       True     False
> # True     False    True
> # True     True     True
> # desired/suiting logic:
> # (BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected))
> 
> def TestLogic( BotWaitForCooldown, CooldownDetected ):
> return BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected) 
> # this logic is flawed, please improve logic.
> 
> if TestLogic( False, False ) == True:
> print "test 1 ok"
> else:
> print "test 1 failed"
> 
> if TestLogic( False, True ) == False:
> print "test 2 ok"
> else:
> print "test 2 failed"
> 
> if TestLogic( True, False ) == True:
> print "test 3 ok"
> else:
> print "test 3 failed"
> 
> if TestLogic( True, True ) == True:
> print "test 4 ok"
> else:
> print "test 4 failed"
> 
> Bye,
>   Skybuck.

I think the logic you're really looking for is:

return BotWaitForCooldown or (not (BotWaitForCooldown or CooldownDetected))

[toc] | [prev] | [next] | [standalone]


#91399

FromMichael Torrie <torriem@gmail.com>
Date2015-05-28 16:16 -0600
Message-ID<mailman.143.1432851416.5151.python-list@python.org>
In reply to#91387
On 05/28/2015 03:58 PM, sohcahtoa82@gmail.com wrote:
> I think the logic you're really looking for is:
> 
> return BotWaitForCooldown or (not (BotWaitForCooldown or CooldownDetected))

Yes this is the simplest form.  For more complicated truth tables you
can create a K map and then apply a reduction algorithm to it.  This is
commonly done in logic circuits to reduce the number of gates to the
minimum.  While not faster, it can be expressed as:

return BotWaitForCooldown or not BotWaitForCooldown and not
CooldownDectected

Order of operations puts the ands above the ors.

[toc] | [prev] | [next] | [standalone]


#91404

FromGrant Edwards <invalid@invalid.invalid>
Date2015-05-28 22:54 +0000
Message-ID<mk86av$7bc$1@reader1.panix.com>
In reply to#91399
On 2015-05-28, Michael Torrie <torriem@gmail.com> wrote:
> On 05/28/2015 03:58 PM, sohcahtoa82@gmail.com wrote:
>> I think the logic you're really looking for is:
>> 
>> return BotWaitForCooldown or (not (BotWaitForCooldown or CooldownDetected))
>
> Yes this is the simplest form.

Not really.


In old school notation, that's
            ___
        A + A+B      

Apply De Morgan's law to the second term        
            _   _
       A + (A * B)

Invert
       ________
            _ _
       A + (A*B)

Apply Demorgan's law once
            _____
       _    _   _
       A * (A * B)

and again for the second term
       _       
       A * (A + B)

Apply the distributive property:

       _     _
       A*A + A*B

The first term is always false, so we can drop it:
       _
       A*B

Now invert it again to cancel out the one we did back a few steps:

       ___
       _
       A*B

De Morgan one last time:
           _
       A + B
       
-- 
Grant Edwards               grant.b.edwards        Yow! Xerox your lunch
                                  at               and file it under "sex
                              gmail.com            offenders"!

[toc] | [prev] | [next] | [standalone]


#91406

FromGrant Edwards <invalid@invalid.invalid>
Date2015-05-28 23:03 +0000
Message-ID<mk86sp$7bc$2@reader1.panix.com>
In reply to#91404
On 2015-05-28, Grant Edwards <invalid@invalid.invalid> wrote:
> On 2015-05-28, Michael Torrie <torriem@gmail.com> wrote:
>> On 05/28/2015 03:58 PM, sohcahtoa82@gmail.com wrote:
>>> I think the logic you're really looking for is:
>>> 
>>> return BotWaitForCooldown or (not (BotWaitForCooldown or CooldownDetected))
>>
>> Yes this is the simplest form.
>
> Not really.
>
>
> In old school notation, that's
>             ___
>         A + A+B      
>
> [...]

That derivation was excessively round-about.  Here is the same thing
in fewer steps:

Invert:
         _______
             ___
         A + A+B      
         
De Morgan:
         _  
         A * (A + B)

Distribute:
         _     _
         A*A + A*B

Drop the null term:
          _
          A*B

Invert (to cancel out the first step)
          ___
          _
          A*B

De Morgan:
            _
          A+B

-- 
Grant Edwards               grant.b.edwards        Yow! I'm reporting for duty
                                  at               as a modern person.  I want
                              gmail.com            to do the Latin Hustle now!

[toc] | [prev] | [next] | [standalone]


#91414

FromMichael Torrie <torriem@gmail.com>
Date2015-05-28 18:52 -0600
Message-ID<mailman.151.1432860747.5151.python-list@python.org>
In reply to#91406
On 05/28/2015 05:03 PM, Grant Edwards wrote:
> On 2015-05-28, Grant Edwards <invalid@invalid.invalid> wrote:
>> On 2015-05-28, Michael Torrie <torriem@gmail.com> wrote:
>>> On 05/28/2015 03:58 PM, sohcahtoa82@gmail.com wrote:
>>>> I think the logic you're really looking for is:
>>>>
>>>> return BotWaitForCooldown or (not (BotWaitForCooldown or CooldownDetected))
>>>
>>> Yes this is the simplest form.
>>
>> Not really.

True enough. My skills from EE are pretty rusty.

[toc] | [prev] | [next] | [standalone]


#91412

Fromsohcahtoa82@gmail.com
Date2015-05-28 17:15 -0700
Message-ID<aa769234-4987-4593-8359-45ea04c533b4@googlegroups.com>
In reply to#91399
On Thursday, May 28, 2015 at 3:17:10 PM UTC-7, Michael Torrie wrote:
> On 05/28/2015 03:58 PM, sohcahtoa82@gmail.com wrote:
> > I think the logic you're really looking for is:
> > 
> > return BotWaitForCooldown or (not (BotWaitForCooldown or CooldownDetected))
> 
> Yes this is the simplest form.  For more complicated truth tables you
> can create a K map and then apply a reduction algorithm to it.  This is
> commonly done in logic circuits to reduce the number of gates to the
> minimum.  While not faster, it can be expressed as:
> 
> return BotWaitForCooldown or not BotWaitForCooldown and not
> CooldownDectected
> 
> Order of operations puts the ands above the ors.

Order of operations might put the ands above the ors, but I still like using parentheses in expressions like that as I think it makes it more clear.

[toc] | [prev] | [next] | [standalone]


#91410

FromDenis McMahon <denismfmcmahon@gmail.com>
Date2015-05-28 23:25 +0000
Message-ID<mk884e$gth$1@dont-email.me>
In reply to#91387
On Thu, 28 May 2015 14:58:19 -0700, sohcahtoa82 wrote:

> On Thursday, May 28, 2015 at 2:50:18 PM UTC-7, Skybuck Flying wrote:
>> Hello,

>> # Desired truth table for BotWaitForCooldown and CooldownDetected 
>> # BotWaitForCooldown:  CooldownDetected: Desired Result:
>> # False                False             True 
>> # False                True              False 
>> # True                 False             True 
>> # True                 True              True 

> I think the logic you're really looking for is:

> return BotWaitForCooldown or (not (BotWaitForCooldown or
> CooldownDetected))

Nope, it simplifies to:

BotWaitForCooldown or not CooldownDetected

-- 
Denis McMahon, denismfmcmahon@gmail.com

[toc] | [prev] | [next] | [standalone]


#91419

From"Skybuck Flying" <skybuck2000@hotmail.com>
Date2015-05-29 04:46 +0200
Message-ID<9dfb3$5567d317$5419aafe$39452@news.ziggo.nl>
In reply to#91410

"Denis McMahon"  wrote in message news:mk884e$gth$1@dont-email.me... 

On Thu, 28 May 2015 14:58:19 -0700, sohcahtoa82 wrote:

> On Thursday, May 28, 2015 at 2:50:18 PM UTC-7, Skybuck Flying wrote:
>> Hello,

>> # Desired truth table for BotWaitForCooldown and CooldownDetected 
>> # BotWaitForCooldown:  CooldownDetected: Desired Result:
>> # False                False             True 
>> # False                True              False 
>> # True                 False             True 
>> # True                 True              True 

> I think the logic you're really looking for is:

> return BotWaitForCooldown or (not (BotWaitForCooldown or
> CooldownDetected))

"
Nope, it simplifies to:

BotWaitForCooldown or not CooldownDetected
"

Apperently it can be simplied even further:

BotWaitForCooldown >= CooldownDetected

Interesting isn't it ? :)

Bye,
  Skybuck.

[toc] | [prev] | [next] | [standalone]


#91389

FromGrant Edwards <invalid@invalid.invalid>
Date2015-05-28 22:01 +0000
Message-ID<mk8376$2qq$1@reader1.panix.com>
In reply to#91385
On 2015-05-28, Skybuck Flying <skybuck2000@hotmail.com> wrote:

> I tried logic below... but funny enough it failed, now I feel like a
> noob lol and share this funny little fail logic with you.
>
> Can you improve/fix the logic ?

> # while DesiredResult==True:
> # Desired truth table for BotWaitForCooldown and CooldownDetected
> # BotWaitForCooldown:  CooldownDetected: Desired Result:
> # False                False             True
> # False                True              False
> # True                 False             True
> # True                 True              True
> # desired/suiting logic:
> # (BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected))

I don't see why you think that's the desired logic, since it doesn't
match your truth table or your test.

> def TestLogic( BotWaitForCooldown, CooldownDetected ):
> return BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected)
> # this logic is flawed, please improve logic.

def TestLogic( BotWaitForCooldown, CooldownDetected ):
    return not ((not BotWaitForCooldown) and CooldownDetected)

works for me...    

-- 
Grant Edwards               grant.b.edwards        Yow! Alright, you!!
                                  at               Imitate a WOUNDED SEAL
                              gmail.com            pleading for a PARKING
                                                   SPACE!!

[toc] | [prev] | [next] | [standalone]


#91394

FromGrant Edwards <invalid@invalid.invalid>
Date2015-05-28 22:11 +0000
Message-ID<mk83qo$2qq$3@reader1.panix.com>
In reply to#91389
On 2015-05-28, Grant Edwards <invalid@invalid.invalid> wrote:
> On 2015-05-28, Skybuck Flying <skybuck2000@hotmail.com> wrote:
>
>> I tried logic below... but funny enough it failed, now I feel like a
>> noob lol and share this funny little fail logic with you.
>>
>> Can you improve/fix the logic ?
>
>> # while DesiredResult==True:
>> # Desired truth table for BotWaitForCooldown and CooldownDetected
>> # BotWaitForCooldown:  CooldownDetected: Desired Result:
>> # False                False             True
>> # False                True              False
>> # True                 False             True
>> # True                 True              True
>> # desired/suiting logic:
>> # (BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected))
>
> I don't see why you think that's the desired logic, since it doesn't
> match your truth table or your test.
>
>> def TestLogic( BotWaitForCooldown, CooldownDetected ):
>> return BotWaitForCooldown or ((not BotWaitForCooldown) and CooldownDetected)
>> # this logic is flawed, please improve logic.
>
> def TestLogic( BotWaitForCooldown, CooldownDetected ):
>     return not ((not BotWaitForCooldown) and CooldownDetected)
>
> works for me...    

While I think that's the most "obvious" solution and can be verified
by inspection: there's only out input state that is "false", so write an expression
for that one state and invert it.

However, you can apply De Morgan's law to simplify it:

       not ((not BotWaitForCooldown) and CooldownDetected)
       
is same as

       (BotWaitForCooldown or (not CooldownDetected))

-- 
Grant Edwards               grant.b.edwards        Yow! Do you have exactly
                                  at               what I want in a plaid
                              gmail.com            poindexter bar bat??

[toc] | [prev] | [next] | [standalone]


#91390

FromTim Chase <python.list@tim.thechases.com>
Date2015-05-28 17:02 -0500
Message-ID<mailman.141.1432850534.5151.python-list@python.org>
In reply to#91385
On 2015-05-28 23:50, Skybuck Flying wrote:
> A = input
> B = input
> C = output
> 
> A B C:
> -------
> F F T
> F T F
> T F T
> T T T
> 
> Surpisingly enough I don't think there is a casual/common operator
> for this thruth table.
> 
> AND does not apply.
> OR does not apply.
> XOR does not apply.

Sounds like you want "a or not b"

>>> print("\n".join("A=%s B=%s: %s" % (a, b, a or not b) for a in (True, False) for b in (True, False)))
A=True B=True: True
A=True B=False: True
A=False B=True: False
A=False B=False: True

-tkc

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.python


csiph-web