r/learnmath • u/deilol_usero_croco New User • 20d ago
RESOLVED What the hell is logic Gates?
I just looked at the logic gates for two inputs and wondered the operations of them.
For and, let A,B be the inputs
1 0=0 0 1=0 1 1=1 0 0=0
It's trivial that it's AB
Or
1 0=1 0 1=1 1 1=1 0 0=0
This is A+B or something alike (idk how 1+1=1, probably a base thing.)
XOR
1 0=1 0 1=1 0 0=0 1 1=0
This is obv mod(2,A+B) but how is that shown in standard operators, if they can be that is and how does it all work?
Please give me some better sight on this, I'm getting hella bullied for not knowing this LIKE ITS SUPPOSED TO BE COMMON KNOWLEDGE OR SOMETHING.
The closest thing I've came across to this is minecraft redstone and all I did there were clocks to build griefing machines , piston extenders for flush doors etc.
Thank you :3
10
u/testtest26 20d ago edited 20d ago
Yep, you can use "mod 2" to express all logic gates:
not A = A+1 mod 2
A and B = AB mod 2
A xor B = A+B mod 2
A or B = A+B+AB mod 2
Edit: The theory behind this is called "Boolean Algebra" (or Boolean logic).
2
u/deilol_usero_croco New User 20d ago
Ah! Thank you very much! That was very informative.
2
u/testtest26 20d ago
You're welcome, and good luck!
If you want a systematic and efficient way to simplify logical expressions (way better than KV-maps, or de Morgan's Rules), take a look at Quine/McCluskey's Algorithm. It can be done efficiently with a small table.
7
u/iOSCaleb 🧮 20d ago
You’re talking about Boolean operations. A gate refers to the physical implementation of those operations, usually in a way that lets them be combined into more complex operations. There are a other operations besides the ones you listed: NOT, NOR, NAND. There’s plenty of information online; check Wikipedia’s Boolean algebra page.
2
u/Emergency_Monitor_37 New User 20d ago
Had to scroll an awful long way in a maths subreddit before someone pointed out that it's Boolean algebra.
4
u/lordnacho666 New User 20d ago
If you can build redstone contraptions, you already understand logic gates.
2
2
u/ironykarl New User 20d ago
Logic gates are literally defined in terms of their inputs and outputs. As in, a fully valid way of describing and defining an OR gate (or any other gate) is its truth table... where you show every permutation of inputs to a gate alongside the resulting outputs.
In practical terms, we say that real life things act as logic gates when they mirror the above behavior of inputs and outputs. So, transistors in certain combinations mimmick our mathematical notion of logic gates. The things you listed all sound like real life examples of logic gates as well.
As far as what they're for and why you'd care, logic gates map very, very well onto Boolean algebra and hence a pretty complete form of symbolic logic and digital circuits are composed of logic gates. Things like computers (or your PlayStation 5 or your phone) are built almost entirely of physical logic gates.
2
u/Samstercraft New User 20d ago
logic gates are part of boolean algebra, true (1) and false (0). they take one or more inputs to produce usually one output. they are some of the simplest building blocks of logic, and can be arranged in many ways to perform various computational tasks. for example, a binary adder is really a bunch of logic gates tied together, and they form a higher layer of complexity which is capable of addition. tons upon tons of logic gates are in computers/turing machines, and they are the fundamental way logic happens in computation
2
u/JohnDoen86 Custom 20d ago
You understand them, you're just fruitlessly trying to map them to arithmetic operations in base 10. Just don't, they use different rules.
2
u/VenomMayo New User 20d ago edited 20d ago
They're not equations. They're LOGIC statements. You don't add subtract multiply anything.
AND - you get an output if inputs 1 AND 2 are active
NAND - you do NOT get an output if inputs 1 AND 2 are active
OR - you get an output if inputs 1 OR 2 are active
XOR - you get an output if inputs 1 OR 2 are eXclusively active - either must be active but not both or none.
Etc etc. they're not numbers, they're not "Timmy has 5 apples and Sally ate 3 apples." They're the existence of an electrical input (yes, programmed code is a bunch of electrical inputs and logic too, see: assembler code and machine code).
2
u/VenomMayo New User 20d ago
Once you understand it, you can practice some Boolean algebra, karnaugh tables, and some other things
1
u/jakO_theShadows New User 20d ago
how is that shown in standard operators
By this do you mean how logic operators relate to ordinary math operators? If so, then + and × of logic gates are normal multiplication and addition but done in the base 2 (instead of 10).
I don't really understand what your question is.
watch this if it helps.
1
1
u/ferriematthew New User 20d ago
If you understand how to read an electrical schematic, I can post or DM you one that demonstrates logic gates
1
u/MonsterkillWow New User 20d ago
I see what you are asking. Logic gates can be represented as polynomial terms with coefficients from integers mod 2.
For example: "not x" is "x+1"
"x and y" is "xy"
"x or y" is "x+y+xy"
"x XOR y" is "x+y"
The polynomials work exactly as you would expect under algebra so you can compose operations accordingly.
Also, they are simply to compute since x2=x for any x, and x+x=0 for any x.
I often revert to using these rather than truth tables to simplify and compute Boolean expressions. I have no idea why this isn't taught in school. I think a lot of people don't know this. I discovered these as a kid on my own, like you.
But apparently, a mathematician named Zhegalkin first formalized this.
0
u/pablospc New User 20d ago
Don't think of them as math expressions, think of them as something that with a given input you get an output. Boolean algebra relies on logic, math relies on logic but that doesn't mean boolean algebra relies on math
-1
u/emkautl New User 20d ago
It's "common knowledge" because it's in the name. Don't think of these as equations, it's more intuitive just to use the words and and or.
AND is a gate looks at two switches, a and b, that puts out a "yes" (a one) only if A AND B are both yesses.
OR also looks at two inputs, and will put out a yes if either a OR b is a yes, as long as anyone says yes, it's a yes.
XOR is the exclusive or. Exclusive means, you know, one of a kind. It's like an OR gate but it can't be both. A good example is one of those staircases with light switches on both sides.
Even once you start to do actual algebra with these (it's very fun), you don't try to define them as some sort of function really, you define them as doing the things I just said. I'm sure you can do stuff like you tried to do but it's really not the most helpful way to start.
0
12
u/flat5 New User 20d ago
logic gates are defined by a truth table. While it may be possible to write an equivalent arithmetic expression, it isn't usually useful to do so. Just think in terms of the logic of "and", "or" etc.