# Functional completeness

Logical connectives :
| NOT | $\neg A$, $-A$, ${\overline {A}}$, $\sim A$ |
| AND | $A\land B$, $A\cdot B$, $AB$, $A\&B$, $A\&\&B$ |
| NAND | $A{\overline {\land }}B$, $A\uparrow B$, $A\mid B$, ${\overline {A\cdot B}}$ |
| OR | $A\lor B$, $A+B$, $A\mid B$, $A\parallel B$ |
| NOR | $A{\overline {\lor }}B$, $A\downarrow B$, ${\overline {A+B}}$ |
| XNOR | $A\ {\text{XNOR}}\ B$ |
| └ equivalent | $A\equiv B$, $A\Leftrightarrow B$, $A\leftrightharpoons B$ |
| XOR | $A{\underline {\lor }}B$, $A\oplus B$ |
| └nonequivalent | $A\not \equiv B$, $A\not \Leftrightarrow B$, $A\nleftrightarrow B$ |
| implies | $A\Rightarrow B$, $A\supset B$, $A\rightarrow B$ |
| nonimplication (NIMPLY) | $A\not \Rightarrow B$, $A\not \supset B$, $A\nrightarrow B$ |
| converse | $A\Leftarrow B$, $A\subset B$, $A\leftarrow B$ |
| converse nonimplication | $A\not \Leftarrow B$, $A\not \subset B$, $A\nleftarrow B$ |
Related concepts :
Propositional calculusPredicate logicBoolean algebraTruth tableTruth functionBoolean functionFunctional completenessScope (logic) :
Applications :
Digital logicProgramming languagesMathematical logicPhilosophy of logic :
Category :
vte :
In logic, a functionally complete set of logical connectives or Boolean operators is one that can be used to express all possible truth tables by combining members of the set into a Boolean expression. A well-known complete set of connectives is { AND, NOT }. Each of the singleton sets { NAND } and { NOR } is functionally complete. However, the set { AND, OR } is incomplete, due to its inability to express NOT.
A gate (or set of gates) that is functionally complete can also be called a universal gate (or a universal set of gates).
In a context of propositional logic, functionally complete sets of connectives are also called (expressively) adequate.
From the point of view of digital electronics, functional completeness means that every possible logic gate can be realized as a network of gates of the types prescribed by the set. In particular, all logic gates can be assembled from either only binary NAND gates, or only binary NOR gates.

## Introduction

Modern texts on logic typically take as primitive some subset of the connectives: conjunction ($\land$); disjunction ($\lor$); negation ($\neg$); material conditional ($\to$); and possibly the biconditional ($\leftrightarrow$). Further connectives can be defined, if so desired, by defining them in terms of these primitives. For example, NOR (the negation of the disjunction, sometimes denoted $\downarrow$) can be expressed as conjunction of two negations:
    $A\downarrow B:=\neg A\land \neg B$
Similarly, the negation of the conjunction, NAND (sometimes denoted as $\uparrow$), can be defined in terms of disjunction and negation. Every binary connective can be defined in terms of $\{\neg ,\land ,\lor ,\to ,\leftrightarrow \}$, which means that set is functionally complete. However, it contains redundancy: this set is not a minimal functionally complete set, because the conditional and biconditional can be defined in terms of the other connectives as
    ${\begin{aligned}A\to B&:=\neg A\lor B\\A\leftrightarrow B&:=(A\to B)\land (B\to A).\end{aligned}}$
It follows that the smaller set $\{\neg ,\land ,\lor \}$ is also functionally complete. (Its functional completeness is also proved by the Disjunctive Normal Form Theorem.) But this is still not minimal, as $\lor$ can be defined as
    $A\lor B:=\neg (\neg A\land \neg B).$
Alternatively, $\land$ may be defined in terms of $\lor$ in a similar manner, or $\lor$ may be defined in terms of $\rightarrow$:
    $\ A\vee B:=\neg A\rightarrow B.$
No further simplifications are possible. Hence, every two-element set of connectives containing $\neg$ and one of $\{\land ,\lor ,\rightarrow \}$ is a minimal functionally complete subset of $\{\neg ,\land ,\lor ,\to ,\leftrightarrow \}$.

## Formal definition

Given the Boolean domain B = {0, 1}, a set F of Boolean functions f$_i$ : B$^{ni}$ → B is functionally complete if the clone on B generated by the basic functions f$_i$ contains all functions f : B$^n$ → B, for all strictly positive integers n ≥ 1. In other words, the set is functionally complete if every Boolean function that takes at least one variable can be expressed in terms of the functions f$_i$. Since every Boolean function of at least one variable can be expressed in terms of binary Boolean functions, F is functionally complete if and only if every binary Boolean function can be expressed in terms of the functions in F.
A more natural condition would be that the clone generated by F consist of all functions f : B$^n$ → B, for all integers n ≥ 0. However, the examples given above are not functionally complete in this stronger sense because it is not possible to write a nullary function, i.e. a constant expression, in terms of F if F itself does not contain at least one nullary function. With this stronger definition, the smallest functionally complete sets would have 2 elements.
Another natural condition would be that the clone generated by F together with the two nullary constant functions be functionally complete or, equivalently, functionally complete in the strong sense of the previous paragraph. The example of the Boolean function given by S(x, y, z) = z if x = y and S(x, y, z) = x otherwise shows that this condition is strictly weaker than functional completeness.

## Characterization of functional completeness

Emil Post proved that a set of logical connectives is functionally complete if and only if it is not a subset of any of the following sets of connectives:
* The monotonic connectives; changing the truth value of any connected variables from F to T without changing any from T to F never makes these connectives change their return value from T to F, e.g. $\vee ,\wedge ,\top ,\bot$.
* The affine connectives, such that each connected variable either always or never affects the truth value these connectives return, e.g. $\neg ,\top ,\bot ,\leftrightarrow ,\nleftrightarrow$.
* The self-dual connectives, which are equal to their own de Morgan dual; if the truth values of all variables are reversed, so is the truth value these connectives return, e.g. $\neg$, maj(p, q, r).
* The truth-preserving connectives; they return the truth value T under any interpretation that assigns T to all variables, e.g. $\vee ,\wedge ,\top ,\rightarrow ,\leftrightarrow$.
* The falsity-preserving connectives; they return the truth value F under any interpretation that assigns F to all variables, e.g. $\vee ,\wedge ,\bot ,\nrightarrow ,\nleftrightarrow$.
Post gave a complete description of the lattice of all clones (sets of operations closed under composition and containing all projections) on the two-element set {T, F}, nowadays called Post's lattice, which implies the above result as a simple corollary: the five mentioned sets of connectives are exactly the maximal nontrivial clones.

## Minimal functionally complete operator sets

When a single logical connective or Boolean operator is functionally complete by itself, it is called a Sheffer function or sometimes a sole sufficient operator. There are no unary operators with this property. NAND and NOR, which are dual to each other, are the only two binary Sheffer functions. These were discovered, but not published, by Charles Sanders Peirce around 1880, and rediscovered independently and published by Henry M. Sheffer in 1913. In digital electronics terminology, the binary NAND gate (↑) and the binary NOR gate (↓) are the only binary universal logic gates.
The following are the minimal functionally complete sets of logical connectives with arity ≤ 2:

### Two elements

    $\{\vee ,\neg \}$, $\{\wedge ,\neg \}$, $\{\to ,\neg \}$, $\{\gets ,\neg \}$, $\{\to ,\bot \}$, $\{\gets ,\bot \}$, $\{\to ,\nleftrightarrow \}$, $\{\gets ,\nleftrightarrow \}$, $\{\to ,\nrightarrow \}$, $\{\to ,\nleftarrow \}$, $\{\gets ,\nrightarrow \}$, $\{\gets ,\nleftarrow \}$, $\{\nrightarrow ,\neg \}$, $\{\nleftarrow ,\neg \}$, $\{\nrightarrow ,\top \}$, $\{\nleftarrow ,\top \}$, $\{\nrightarrow ,\leftrightarrow \}$, $\{\nleftarrow ,\leftrightarrow \}.$

### Three elements

    $\{\lor ,\leftrightarrow ,\bot \}$, $\{\lor ,\leftrightarrow ,\nleftrightarrow \}$, $\{\lor ,\nleftrightarrow ,\top \}$, $\{\land ,\leftrightarrow ,\bot \}$, $\{\land ,\leftrightarrow ,\nleftrightarrow \}$, $\{\land ,\nleftrightarrow ,\top \}.$
There are no minimal functionally complete sets of more than three at most binary logical connectives. In order to keep the lists above readable, operators that ignore one or more inputs have been omitted. For example, an operator that ignores the first input and outputs the negation of the second can be replaced by a unary negation.

## Examples

* Examples of using the NAND (↑) completeness. As illustrated by,
** ¬A ≡ A ↑ A
** A ∧ B ≡ ¬(A ↑ B) ≡ (A ↑ B) ↑ (A ↑ B)
** A ∨ B ≡ (¬A) ↑ (¬B) ≡ (A ↑ A) ↑ (B ↑ B)
* Examples of using the NOR (↓) completeness. As illustrated by,
** ¬A ≡ A ↓ A
** A ∨ B ≡ ¬(A ↓ B) ≡ (A ↓ B) ↓ (A ↓ B)
** A ∧ B ≡ (¬A) ↓ (¬B) ≡ (A ↓ A) ↓ (B ↓ B)
Note that an electronic circuit or a software function can be optimized by reuse, to reduce the number of gates. For instance, the "A ∧ B" operation, when expressed by ↑ gates, is implemented with the reuse of "A ↑ B",
    X ≡ (A ↑ B); A ∧ B ≡ X ↑ X

## In other domains

Apart from logical connectives (Boolean operators), functional completeness can be introduced in other domains. For example, a set of reversible gates is called functionally complete, if it can express every reversible operator.
The 3-input Fredkin gate is functionally complete reversible gate by itself – a sole sufficient operator. There are many other three-input universal logic gates, such as the Toffoli gate.
In quantum computing, the Hadamard gate and the T gate are universal, albeit with a slightly more restrictive definition than that of functional completeness.

## Set theory

There is an isomorphism between the algebra of sets and the Boolean algebra, that is, they have the same structure. Then, if we map boolean operators into set operators, the "translated" above text are valid also for sets: there are many "minimal complete set of set-theory operators" that can generate any other set relations. The more popular "Minimal complete operator sets" are {¬, ∩} and {¬, ∪}. If the universal set is forbidden, set operators are restricted to being falsity (Ø) preserving, and cannot be equivalent to functionally complete Boolean algebra.