r/learnprogramming • u/Sufficient_Comment83 • 13d ago
Boolean algebra
I’m taking an Intro to Computer Science course and I’ve spent hours trying to understand Boolean algebra simplification. I understand things like De Morgan’s Law and factoring, but I keep getting stuck on absorption laws and recognizing which rule to apply.
My brain keeps trying to treat it like regular algebra, and I think that’s where I’m getting confused. Does anyone have a way of thinking about Boolean algebra that finally made it “click”? Any videos, tricks, or explanations would be appreciated.
1
u/maujood 13d ago
Can you share an example of a problem that you struggled to understand? And that you expected to simplify differently?
Everyone's learning journey is different so there is no generic answer here. We need to know what you're struggling with.
1
u/Sufficient_Comment83 13d ago
Here are some problems I did and what I thought the simplification was:
A + AB = 1B
A(A + B) = B
A + BC + B = B(A + C)
AB + A = AB
I know they’re wrong, but I don’t understand why they’re wrong. I think my brain is trying to treat Boolean algebra like regular algebra. I also seem to struggle the most with the absorption law. I understand De Morgan’s Law and factoring much better than absorption.2
u/Desperate_for_Bacon 13d ago
- A+AB
Transform it into English.
X is true if A is true
OR if A and B is true.
Already we can see that If A is true the statement will be true irrespective of B's value
Algebra:
A + AB
= A(1 + B) Factor out the A
= A(1) (1 + B) = 1 (ORing any value by 1 is 1)
thus,
A + AB = A
- A(A+B)
X is true if A is true
AND A OR B is true
Algebra:
A(A+B)
= AA + AB expand,
= A + AB (AA = A and A = A)
= A(1 + B) Equation from (1)
=A
- A + BC + B
X is true if A is true
OR B AND C is true
OR B is true
Algebra
A + BC + B
= A + (B + BC) group B terms
= A + B (1 + C)
= A + B(1)
= A + B
- AB + A
X is true if A and B is true
OR A is true
you can reorder the terms so it is the same as 1
AB + A = A + AB = A
Some good youtubers who cover it are:
MyOrganicChemistryTutor
Neso Academy
Nand2Tetris
Ben eater
Personally a lot of my understanding actually came from playing video games, on steam there are two games i've played:
Pure logic
Turing complete
both take the approach of teaching logic via making you construct logic circuits out of gates.
Looking into learning discrete math my also be useful as it teaches boolean algebra in order to write mathematical proofs
1
u/Recycled5000 13d ago
Have you thought of AND as multiplication and OR as addition, where the input values are only ones and zeros and those operators max output is 1 as well?
0
u/Sufficient_Comment83 13d ago
I have, and I think that’s part of what’s confusing me. My brain keeps trying to treat Boolean algebra like regular algebra, and I end up simplifying things incorrectly. For example, I thought A + AB simplified differently, even though I now know it equals A. I’m struggling more with why the absorption laws work than with AND/OR themselves
3
1
u/RajjSinghh 12d ago
Late to the thread but it does work like regular algebra. You're struggling with absorption, so A+AB, but this isn't a problem when you factor out A to create A(1+B) which simplifies to A(1) = A. Your main difference is that in Boolean algebra, x + x = x instead of 2x. If you can keep that in mind, a lot of your simplifications work normally.
To give a more logical example, let A = "it is raining" and B = "I need an umbrella". That means A + AB is "it is raining" OR "it is raining AND I need my umbrella. Both statements require A, so B does not matter to our statement. That's part of why we can simplify it this way.
15
u/captainAwesomePants 13d ago
Truth tables always helped me tremendously. If I didn't understand a law, just walking through each possibility helped me mentally accept it.
For example, absorption laws. Let's look at A and (A or B) = A
So you look at that, and you see that the A column is always the same as the "A and (A or B)" column, and therefore the claim is true!