# How to make a implication gate using command blocks?

I have tons of two-lever implication gates in a map I'm making, and in some cases there isn't enough space to place it. The gate, a bit expanded for simplicity, looks like this:

This setup does not output signal only when input 2 is on and input 1 is off (so it's kind of a reverse implication, but with the same functionality). Currently, my setup takes up 4x2x8 (64) blocks.

How can this gate be simplified and/or compacted? How small can it get with command blocks?

Edit: I found a partial answer, but the command block solution has yet to be found.

• There is a way to do this with command blocks, but it would be larger than the one above, however, there wouldn't need to be any redstone connection to the lamp, so the levers and/or lamp(s) could be placed anywhere.
– ALX
Commented Nov 10, 2016 at 21:07

Lower: `execute if block ~ ~ ~-1 minecraft:redstone_block unless block ~ ~1 ~-1 minecraft:redstone_block run setblock ~ ~1 ~ minecraft:redstone_block`

Upper: `setblock ~ ~-1 ~ minecraft:air`

Both: repeat, unconditional, always active

• Looks interesting, I'll be checking it out soon, thanks! Commented Nov 15, 2019 at 20:22

This answer won't explain how to make an implication gate using command blocks, it just solves the problem of too little space for the logical gate

You could try building the setup far away, then hooking up two levers to two seperate command blocks. `Lever 1` activates `Command Block 1` which places a redstone block in front of `Input 1 (in your picture)`, activating it. Then you do the same again: `Lever 2` activates `Command Block 2`, which places a command block in front of `Input 2 in your picture`. Then you can hook the `Output (in your picture)` up to another command block which can 1) Place a redstone block where you want a redstone impulse OR 2) You can just enter a command in that command block which will be activated

This way you will have enough space for your logical gates!

If you do not want to use redstone (which is a good idea for various reasons) or even no command blocks at all, you can use tags in a very easy way to do this.

As an overview, this is the logic gate of an "IMPLY gate", "`A`" and "`B`" being the inputs and "`O`" being the output of `A→B`:

``````┌─┬─┬─┐
│A│B│O│
├─┼─┼─┤
│0│0│1│
│0│1│1│
│1│0│0│
│1│1│1│
└─┴─┴─┘
``````

So this means that the output is only off if A is on and B off (because only then the statement "if A, then B" is false). But this also means that you can easily check for A being true and B being false and then invert the output, which can be done with tags like this:

``````/execute unless entity @s[tag=A,tag=!B] run <command>
``````

This `<command>` will always run unless you have the tag A and not the tag B, meaning that A has to imply B.

You can compact the gate to 3x2x4 = 24 blocks like this when both inputs are off (the redstone lamp is the output):

And that's the lowest amount of blocks you can get to without using command blocks, I'd say.