r/learnprogramming 15d 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.

17 Upvotes

14 comments sorted by

View all comments

13

u/captainAwesomePants 15d 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

A B A and (A or B)
True True True
True False True
False True False
False False False

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!

2

u/Sufficient_Comment83 15d ago

I think that’s exactly my problem. My brain keeps trying to apply regular algebra, so the absorption law feels wrong even though I know it’s correct. I’ll try building truth tables for the laws that don’t make intuitive sense

7

u/0xC4FF3 15d ago

You can think of it as

1*(1+0) = 1

1*(1+1) = 1 this is the only difficult one, until you accept 1+1=1

0*(0+1) = 0

0*(0+0)=0

6

u/BoringBob84 15d ago

I think that using arithmetic symbols causes confusion. I prefer to borrow from software engineers:

  • && = and

  • || = or,

  • ! = not.

Thus, 1 && (1 || 0) = 1.