Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1075927 Posts in 44152 Topics- by 36120 Members - Latest Member: Royalhandstudios

December 29, 2014, 03:55:32 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)De morgan's laws, and boolean logic discussion thread
Pages: [1]
Print
Author Topic: De morgan's laws, and boolean logic discussion thread  (Read 1613 times)
tergem
Level 1
*

It's a pony!


View Profile
« on: March 15, 2011, 01:44:35 PM »

Alright, I as a self-taught programmer Hand Metal Left finally started getting real-schooling in programming.

So I don't think I get De Morgan's laws Embarrassed. This is embarrassing. Especially in a class where before this everything I have already learned. So I think it is pretty much a(b+c) = (ab)-(ac)

a= not/is
b=Boolean one (E.g x>4)
+=or
-=and
c= Boolean two.

Is this even remotely close what I am supposed to be getting?
« Last Edit: March 18, 2011, 09:18:32 PM by tergem » Logged

Games made so far (completed):Spike teh dodge, Unnamed puzzle game, Galaga clone, Generic Top-Down Shooter, overly simplistic business simulator In dev: Platformer!
increpare
Guest
« Reply #1 on: March 15, 2011, 02:21:55 PM »

if you want the analogy, treat it as

not x = -x
x and y = x*y
x or y = x+y

This isn't exactly right. Tell me where this breaks down, or how to make it more exact.
Logged
bateleur
Level 10
*****



View Profile
« Reply #2 on: March 15, 2011, 02:49:44 PM »

DeMorgan's laws are actually pretty easy once you get rid of all the silly notation. Best way to understand them is with examples.

1) NOT (P AND Q) = (NOT P) OR (NOT Q)

Example: "This is not a big, red thing" means it must either be not big or not red.

2) NOT (P OR Q) = (NOT P) AND (NOT Q)

Example: "This is not either big or red" means it's not big and also not red.
Logged

Triplefox
Level 9
****



View Profile WWW Email
« Reply #3 on: March 15, 2011, 03:05:02 PM »

I had to look up what you were talking about, turns out that I never need to think about it in the "low level" way - I just intuitively know/have memorized that the properties of logic allow me to do that. These properties, including De Morgan's, are similar in nature to the properties of arithmetic. (commutative, associative, etc.) So yes you are on the right track, generally.

The main differences are that: they are specific to the vocabulary of logic, and instead of being defined true, they can be derived in various ways from arithmetic or set theory. It's not going to be completely equivalent to arithmetic properties. If in doubt, learn how to derive it so you can feel confident about what's going on. Math is all about the relationships after all.
Logged

Overkill
Level 3
***


Andrew G. Crowell

overkill9999@gmail.com Minimum+Overkill
View Profile WWW Email
« Reply #4 on: March 15, 2011, 03:17:03 PM »

To understand DeMorgan's Laws, it might help to look at a boolean algebra over the elements {0, 1}, in terms of truth tables. Note that there are other boolean algebras for which there are other elements (for instance, fuzzy logic), so this is not an acceptable mathematical proof, but just provides some basic understanding.

p or q:
pqp or q
000
011
101
111

p and q:
pqp and q
000
010
100
111

not p:
pnot p
01
10


Now, let's use the above truth tables to check out DeMorgan's Laws in action.

not (p and q) vs. not p or not q:
pqnot (p and q)not p or not q
0011
0111
1011
1100

not (p or q) vs. not p and not q:
pqnot (p or q)not p and not q
0011
0100
1000
1100

Anyways, this should give you some understand as to why, in a sort of hand-wavey way. You can definitely prove both properties using the fundamental properties of boolean algebra, but I won't do that (unless I feel bored later). Again, truth tables aren't a mathematical proof.

Quote from: increpare
if you want the analogy, treat it as

not x = -x
x and y = x*y
x or y = x+y

This isn't exactly right. Tell me where this breaks down, or how to make it more exact.

I have a few nitpicks :D

x or y isn't equivalent to x + y, because x + y is not necessarily defined for a boolean algebra, or if it could be defined, it might not be closed over the set that a boolean algebra might consider. The set {T, F} may have no meaningful way of adding its elements. Addition isn't closed under the set {0, 1} (1 + 1 is outside the set {0, 1}). Addition modulo 2 is closed under {0, 1} but this is exclusive or.

Likewise, not x isn't equivalent to -x, because it isn't arithmetic negation. In general, logical and arithmetic negation are quite different because not 0 = 1 while -0 = 0.

Furthermore, x and y might not be defined as x * y depending on the algebra, but in fact be something like min(x, y) which gives rather different results for other elements in the set besides the unit element 1 and zero element 0.
« Last Edit: March 15, 2011, 04:21:55 PM by Overkill » Logged

tergem
Level 1
*

It's a pony!


View Profile
« Reply #5 on: March 15, 2011, 04:05:26 PM »

Thank you comrades!
DeMorgan's laws are actually pretty easy once you get rid of all the silly notation. Best way to understand them is with examples.

1) NOT (P AND Q) = (NOT P) OR (NOT Q)

Example: "This is not a big, red thing" means it must either be not big or not red.

2) NOT (P OR Q) = (NOT P) AND (NOT Q)

Example: "This is not either big or red" means it's not big and also not red.


The examples made it easier for me.

However I like where some of the posts are going, so please allow this thread to continue!
Logged

Games made so far (completed):Spike teh dodge, Unnamed puzzle game, Galaga clone, Generic Top-Down Shooter, overly simplistic business simulator In dev: Platformer!
mcc
Level 10
*****


glitch


View Profile WWW Email
« Reply #6 on: March 15, 2011, 08:48:42 PM »

Quote from: increpare
if you want the analogy, treat it as

not x = -x
x and y = x*y
x or y = x+y

This isn't exactly right. Tell me where this breaks down, or how to make it more exact.

I have a few nitpicks :D

x or y isn't equivalent to x + y, because x + y is not necessarily defined for a boolean algebra, or if it could be defined, it might not be closed over the set that a boolean algebra might consider. The set {T, F} may have no meaningful way of adding its elements. Addition isn't closed under the set {0, 1} (1 + 1 is outside the set {0, 1}). Addition modulo 2 is closed under {0, 1} but this is exclusive or.

Likewise, not x isn't equivalent to -x, because it isn't arithmetic negation. In general, logical and arithmetic negation are quite different because not 0 = 1 while -0 = 0.

Furthermore, x and y might not be defined as x * y depending on the algebra, but in fact be something like min(x, y) which gives rather different results for other elements in the set besides the unit element 1 and zero element 0.
I'm actually pretty sure I've seen the +/*/- notation increpare offers actually used as the standard way of describing boolean operations in some electrical engineering classes...

I'm not 100% sure on the definition of a boolean algebra, but I will note, as per wikipedia, that if we use increpare's operations but take + as XOR rather than OR we have a valid ring over {0,1} as per the ring axioms Tongue
Logged

My projects:<br />Games: Jumpman Retro-futuristic platforming iJumpman iPhone version Drumcircle PC+smartphone music toy<br />More: RUN HELLO
Pishtaco
Level 10
*****



View Profile WWW
« Reply #7 on: March 15, 2011, 10:16:52 PM »

What bateleur said. Once you understand truth tables, you understand how logical connectives work, and "De Morgan's laws" is just a shorthand way of referring to some commonsense properties of some of them. I wouldn't worry about general Boolean algebras unless you need to; they're not relevant to most things you do with logical connectives.

[and to contribute some (old-fashioned) notation from logic: P & Q <-> ~(~P v ~Q) ]
Logged

X3N
Level 6
*


View Profile Email
« Reply #8 on: March 17, 2011, 07:20:21 AM »

Related? http://en.wikipedia.org/wiki/Transposition_%28logic%29
Logged

destiny is truth pre-op
tergem
Level 1
*

It's a pony!


View Profile
« Reply #9 on: March 17, 2011, 01:32:21 PM »

Thanks to you guys I passed the quiz with 100% right Smiley. Good job!
Logged

Games made so far (completed):Spike teh dodge, Unnamed puzzle game, Galaga clone, Generic Top-Down Shooter, overly simplistic business simulator In dev: Platformer!
Pineapple
Level 10
*****


Love, love is a verb Love is a doing word ~♪


View Profile WWW
« Reply #10 on: March 17, 2011, 01:59:40 PM »

Binary algebra is my favorite algebra. I designed my own 2-bit binary multiplier once using logic gates.
Logged

InfiniteStateMachine
Level 10
*****



View Profile WWW Email
« Reply #11 on: March 18, 2011, 08:32:03 PM »

yeah, boolean algebra and logical inference are kind of like relaxing fun math once you get the rules down.
Logged

Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic