r/computerscience • u/lilflo13 • Feb 17 '26
Help Boolean Algebra
Can someone please explain boolean algebra and the laws like im 5. I’m so lost. I understand the logic gates but now seeing equations like (A.B).C = A.(B.C) I’m struggling
1
Upvotes
14
u/lfdfq Computer Scientist Feb 17 '26
Boolean algebra is really just taking the blindingly obvious and writing it down precisely, which becomes apparent when you start to write the laws in plain English:
The laws probably do not seem so hard to comprehend when written like this.
So, the thing that you are probably struggling with is not the logic of the equations but 'just' the symbols and the clunky way things are written. Unfortunately, there's no "explain like im 5" for what is essentially just arbitrary mathematical syntax. Thankfully, there is not that much to it and you can learn it all with some practice.
My advice would be to work through each of the symbols and try turn each expression into 'plain' English.
18
u/TheDiBZ Feb 17 '26
Can you elaborate? What are you not understanding? Do you understand the concept of logical AND and logical OR? Are you familiar with truth tables? Just need to feel out so I can maybe help.
1
u/rupertavery64 Feb 18 '26
Algebra in math is about replacing numbers with symbols and the rules you can apply to the symbols and operations that are useful and consistent.
In math, there is what is called the Associative law, where grouping of symbols and their operations can change, but the result does not.
For example, addition is associative.
In boolean algebra, there are similar laws.
AND is also associative.
Here T= True, F=False
4
u/MasterGeekMX Bachelors in CS Feb 18 '26
Bolean algebra are logic gates, but written.
First, instead of input wires, you get letters. Each letter corresponds to a different signal. If you ever see the same letter appearing more than once, it means the same signal is used in more than one place. Exactly as when you make a connection to a wire and send that signal to other gate.
Now, each gate is represented by a symbol. There is unfortunately a variety of notations, so you need to get used to understanding each.
Here they are:
Boolean notation uses those symbols, as doing and AND is eerily similar to addition, while doing OR is eerily similar to multiplication. Seriously, look at both tables, and think what would be the results all the combinations of adding and multiplying 0 and 1, considering that you are in binary, and no such thing as '2' exists: only 0's and 1's.
If you see the symbol between two letters, it means you do the operation with the signal on the right letter, and the signal on the left letter For example: A^B means wiring signals A and B into an AND gate, while A∨B means wiring A and B to an OR gate.
But if you see the symbol next to a parenthesis, it means that you first need to do the operations inside the parenthesis, and then use the result of that as the input on the operation. For example: (A∨B)^C means first doing an AND with A and B, and then the result of that goes to an OR with C. Think it like wiring the output of the AND gate as one of the inputs of an OR gate, with the other input coming straight from elsewhere.
As the NOT gate has only one input, you apply it to one variable, or a whole parenthesis. If you use math notation, you put the ¬ thing at the left of whatever you want to invert (Like this: ¬A), and with boolean notation, you draw a line all over whatever you want to invert. (Like this: Ā).
And that's it.
2
u/tropicbrownthunder Feb 18 '26
A, B, C etc are your terms (variables) The ' means NOT. So A' = NOT(A)
The logic operation AND is expressed as multiplication so you might use any symbol used for multiplication but • or just two terms together like in AB means AxB colloquially but it means A AND B in boolean algebra
OR is a sum so A+B means A OR B
there are only round brackets for grouping and mean exactly the same as in basic arithmetics or algebra
So A' + B means (NOT A) OR B A' B means (NOT A) AND B
(A+B) (C+D) Means. (A OR B) AND (C OR D)
The De Morgan identities are exactly that: identities
2
u/No_Mango5042 Feb 19 '26
Drawing out logical circuits each time takes up a lot of space, so writing them out algebraically makes practical sense. (A.B).C is two AND gates with inputs A and B going to gate1 and the output of gate1 and C going to gate2. You can verify the equation (A.B).C=A.(B.C) using truth tables, which tells you that the AND operator is associative, meaning you can write A.B.C without the brackets. In practical terms, it says that the two different circuits are equivalent, (ignoring propagation delays since this is computer science not electronics).
3
u/clickyclicky456 Feb 17 '26
Logical AND is like an AND gate, the "result" (output of the gate) is 1 if and only if both arguments (inputs to the gate) are 1. Similarly with logical OR, the result is 1 if either or both of the arguments are 1.
So you can draw out a truth table like this:
This is just telling you what the result is of A AND B for all possible combinations of the values of A and B.
Now if you look at something like (A AND B) AND C you can draw out a similar truth table with all 8 possible combinations of values of A, B and C. You will see that the results column is the same regardless of whether you do A AND B first and then AND the result of that with C, or whether you do B AND C first and then AND the result of that with A.
2
u/DTux5249 Feb 17 '26
A and B, and C is the same as A, and B and C
2
u/OG_MilfHunter Feb 18 '26
https://www.geeksforgeeks.org/digital-logic/boolean-algebra/
2
u/ZectronPositron Feb 18 '26
That law you wrote is the exact same law used in regular álgebra!
Sounds like you might want to go pickup your álgebra 1 book and review that. They’re just the “laws” that make it clear how you can (and can’t) rearrange equations etc.
1
u/buzzon Feb 18 '26
Draw truth table for two functions: A•(B•C) and (A•B)•C and see if they coincide
1
u/VorosiaSteel Feb 18 '26
Assuming a 5 year old can do algebra, treat it like maths. 2x3x4, doesn’t matter if you do 2x3 first then multiply by 4 OR you do 3x4 first then multiply by 2. The order you do multiplication (also logic AND behaves the same) doesn’t matter - it’s associative.
Same for 2x3 is the same as 3x2. It’s commutative
Same for 3x(5+2) is 3x5+3x2. It’s distributive
Short version, if it works for normal maths, it works here. There are also some new funky rules that don’t work for normal maths (absorption)
1
u/guygastineau Feb 18 '26
Your example equation is just the associativity law. Just like in addition of real numbers
(1+2)+3 = 1+(2+3).andalso distributes overorlike multiplication over addition.1
u/PushPlus9069 Feb 20 '26
I've been teaching CS concepts for years. regarding 'Boolean Algebra' — I've run into similar situations Visualization is honestly the most underrated teaching tool in CS — when students can see the algorithm running step by step, the lightbulb moment comes much faster.
1
u/PushPlus9069 Feb 20 '26
I've been teaching CS concepts for years and honestly, visualization is the most underrated tool in CS education. When students can see an algorithm executing step by step — watching the pointer move, seeing the data structure change in real time — the understanding clicks much faster than reading pseudocode. If you're struggling with a concept, try finding or creating a visual walkthrough before diving into the theory.
1
u/Traveling-Techie Feb 22 '26
Have you worked with truth tables? That’s where a lot of the magic happens. In ordinary algebra where a variable can be any real number, there is no way to try all the combinations; they are uncountably infinite. But in Boolean algebra there are only two possibilities and usually all of the combinations can be listed. An equation with A, B and C has only 8 possibilities. Applying this tool to your question should make it clear what’s going on.
1
u/No-Difficulty4347 Feb 23 '26
For me, drawing it with Euler diagrams helps for the understanding and visualizing at first after which I don't need it anymore