Redstone circuits/Logic

A logic gate can be thought of as a simple device that will return a number of outputs, determined by the pattern of inputs and rules that the logic gate follows. For example, if both inputs in an AND gate are in the 'true'/'on'/'powered'/'1' state, then the gate will return 'true'/'on'/'powered'/'1'.

There are many different kinds of logic gate, each of which can be implemented with many different designs. Each design has various advantages and disadvantages, such as size, complexity, speed, maintenance overhead, or cost. The various sections will give many different designs for each gate type.

Concepts
The output of each logic circuit reflects the state of its inputs at all times (though possibly with some delay incurred by the circuit).


 * Swapping inputs


 * For most of these gates, you can swap A and B without changing the output (i.e., they are commutative).


 * Swapping the inputs of the IMPLIES gate will affect its output, and the NOT gate has only one input.


 * Stacking inputs


 * The AND, OR, and XOR gates can each be used in arrays to perform their operation on more than two inputs, by taking two inputs for the first gate, combining its output with another input, and continuing this process until a single output results. For these gates, the order in which the inputs are combined doesn't matter (i.e., they are associative).


 * When an XNOR gate is combined in this way, its output is on when an odd number of inputs is on.