# Truth function

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\odot B,{\overline {A{\overline {\lor }}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 truth function is a function that accepts truth values as input and produces a unique truth value as output. In other words: the input and output of a truth function are all truth values; a truth function will always output exactly one truth value, and inputting the same truth value(s) will always output the same truth value. The typical example is in propositional logic, wherein a compound statement is constructed using individual statements connected by logical connectives; if the truth value of the compound statement is entirely determined by the truth value(s) of the constituent statement(s), the compound statement is called a truth function, and any logical connectives used are said to be truth functional.
Classical propositional logic is a truth-functional logic, in that every statement has exactly one truth value which is either true or false, and every logical connective is truth functional (with a correspondent truth table), thus every compound statement is a truth function. On the other hand, modal logic is non-truth-functional.

## Overview

A logical connective is truth-functional if the truth-value of a compound sentence is a function of the truth-value of its sub-sentences. A class of connectives is truth-functional if each of its members is. For example, the connective "and" is truth-functional since a sentence like "Apples are fruits and carrots are vegetables" is true if, and only if, each of its sub-sentences "apples are fruits" and "carrots are vegetables" is true, and it is false otherwise. Some connectives of a natural language, such as English, are not truth-functional.
Connectives of the form "x believes that ..." are typical examples of connectives that are not truth-functional. If e.g. Mary mistakenly believes that Al Gore was President of the USA on April 20, 2000, but she does not believe that the moon is made of green cheese, then the sentence
    "Mary believes that Al Gore was President of the USA on April 20, 2000"
is true while
    "Mary believes that the moon is made of green cheese"
is false. In both cases, each component sentence (i.e. "Al Gore was president of the USA on April 20, 2000" and "the moon is made of green cheese") is false, but each compound sentence formed by prefixing the phrase "Mary believes that" differs in truth-value. That is, the truth-value of a sentence of the form "Mary believes that..." is not determined solely by the truth-value of its component sentence, and hence the (unary) connective (or simply operator since it is unary) is non-truth-functional.
The class of classical logic connectives (e.g. &, →) used in the construction of formulas is truth-functional. Their values for various truth-values as argument are usually given by truth tables. Truth-functional propositional calculus is a formal system whose formulae may be interpreted as either true or false.

## Table of binary truth functions

In two-valued logic, there are sixteen possible truth functions, also called Boolean functions, of two inputs P and Q. Any of these functions corresponds to a truth table of a certain logical connective in classical logic, including several degenerate cases such as a function not depending on one or both of its arguments. Truth and falsehood are denoted as 1 and 0, respectively, in the following truth tables for sake of brevity.
Contradiction/False :
| Contradiction/False Notation Equivalent formulas Truth table Venn diagram $\bot$ "bottom" P ∧ ¬P Opq   Q 0 1 P 0   0   0  1   0   0 | Tautology/True Notation Equivalent formulas Truth table Venn diagram $\top$ "top" P ∨ ¬P Vpq   Q 0 1 P 0   1   1  1   1   1 |
| Proposition P Notation Equivalent formulas Truth table Venn diagram P p Ipq   Q 0 1 P 0   0   0  1   1   1 | Negation of P Notation Equivalent formulas Truth table Venn diagram ¬P ~P Np Fpq   Q 0 1 P 0   1   1  1   0   0 |
| Proposition Q Notation Equivalent formulas Truth table Venn diagram Q q Hpq   Q 0 1 P 0   0   1  1   0   1 | Negation of Q Notation Equivalent formulas Truth table Venn diagram ¬Q ~Q Nq Gpq   Q 0 1 P 0   1   0  1   1   0 |
| Conjunction Notation Equivalent formulas Truth table Venn diagram P ∧ Q P & Q P · Q P AND Q P ↛¬Q ¬P ↚ Q ¬P ↓ ¬Q Kpq   Q 0 1 P 0   0   0  1   0   1 | Non-conjunction/Alternative denial Notation Equivalent formulas Truth table Venn diagram P ↑ Q P | Q P NAND Q P → ¬Q ¬P ← Q ¬P ∨ ¬Q Dpq   Q 0 1 P 0   1   1  1   1   0 |
| Disjunction Notation Equivalent formulas Truth table Venn diagram P ∨ Q P OR Q P ← ¬Q ¬P → Q ¬P ↑ ¬Q ¬(¬P ∧ ¬Q) Apq   Q 0 1 P 0   0   1  1   1   1 | Non-disjunction/Joint denial Notation Equivalent formulas Truth table Venn diagram P ↓ Q P NOR Q P ↚ ¬Q ¬P ↛ Q ¬P ∧ ¬Q Xpq   Q 0 1 P 0   1   0  1   0   0 |
| Material nonimplication Notation Equivalent formulas Truth table Venn diagram P ↛ Q P $\not \supset$ Q P $>$ Q P NIMPLY Q P ∧ ¬Q ¬P ↓ Q ¬P ↚ ¬Q Lpq   Q 0 1 P 0   0   0  1   1   0 | Material implication Notation Equivalent formulas Truth table Venn diagram P → Q P ⊃ Q P $\leq$ Q P IMPLY Q P ↑ ¬Q ¬P ∨ Q ¬P ← ¬Q Cpq   Q 0 1 P 0   1   1  1   0   1 |
| Converse nonimplication Notation Equivalent formulas Truth table Venn diagram P ↚ Q P $\not \subset$ Q P $<$ Q P ↓ ¬Q ¬P ∧ Q ¬P ↛ ¬Q Mpq   Q 0 1 P 0   0   1  1   0   0 | Converse implication Notation Equivalent formulas Truth table Venn diagram P ← Q P ⊂ Q P $\geq$ Q P ∨ ¬Q ¬P ↑ Q ¬P → ¬Q Bpq   Q 0 1 P 0   1   0  1   1   1 |
| Non-equivalence/Exclusive disjunction Notation Equivalent formulas Truth table Venn diagram P ↮ Q P ≢ Q P ⨁ Q P XOR Q P $\leftrightarrow$ ¬Q ¬P $\leftrightarrow$ Q ¬P ↮ ¬Q Jpq   Q 0 1 P 0   0   1  1   1   0 | Equivalence/Biconditional Notation Equivalent formulas Truth table Venn diagram P $\leftrightarrow$ Q P ≡ Q P XNOR Q P IFF Q P ↮ ¬Q ¬P ↮ Q ¬P $\leftrightarrow$ ¬Q Epq   Q 0 1 P 0   1   0  1   0   1 |

## Functional completeness

Because a function may be expressed as a composition, a truth-functional logical calculus does not need to have dedicated symbols for all of the above-mentioned functions to be functionally complete. This is expressed in a propositional calculus as logical equivalence of certain compound statements. For example, classical logic has ¬P ∨ Q equivalent to P → Q. The conditional operator "→" is therefore not necessary for a classical-based logical system if "¬" (not) and "∨" (or) are already in use.
A minimal set of operators that can express every statement expressible in the propositional calculus is called a minimal functionally complete set. A minimally complete set of operators is achieved by NAND alone {↑} and NOR alone {↓}.
The following are the minimal functionally complete sets of operators whose arities do not exceed 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 \}$.

## Algebraic properties

Some truth functions possess properties which may be expressed in the theorems containing the corresponding connective. Some of those properties that a binary truth function (or a corresponding logical connective) may have are:
* associativity: Within an expression containing two or more of the same associative connectives in a row, the order of the operations does not matter as long as the sequence of the operands is not changed.
* commutativity: The operands of the connective may be swapped without affecting the truth-value of the expression.
* distributivity: A connective denoted by · distributes over another connective denoted by +, if a · (b + c) = (a · b) + (a · c) for all operands a, b, c.
* idempotence: Whenever the operands of the operation are the same, the connective gives the operand as the result. In other words, the operation is both truth-preserving and falsehood-preserving (see below).
* absorption: A pair of connectives $\land ,\lor$ satisfies the absorption law if $a\land (a\lor b)=a\lor (a\land b)=a$ for all operands a, b.
A set of truth functions is functionally complete if and only if for each of the following five properties it contains at least one member lacking it:
* monotonic: If f(a$_1$, ..., a$_n$) ≤ f(b$_1$, ..., b$_n$) for all a$_1$, ..., a$_n$, b$_1$, ..., b$_n$ ∈ {0,1} such that a$_1$ ≤ b$_1$, a$_2$ ≤ b$_2$, ..., a$_n$ ≤ b$_n$. E.g., $\vee ,\wedge ,\top ,\bot$.
* affine: For each variable, changing its value either always or never changes the truth-value of the operation, for all fixed values of all other variables. E.g., $\neg ,\leftrightarrow$, $\not \leftrightarrow ,\top ,\bot$.
* self dual: To read the truth-value assignments for the operation from top to bottom on its truth table is the same as taking the complement of reading it from bottom to top; in other words, f(¬a$_1$, ..., ¬a$_n$) = ¬f(a$_1$, ..., a$_n$). E.g., $\neg$.
* truth-preserving: The interpretation under which all variables are assigned a truth value of true produces a truth value of true as a result of these operations. E.g., $\vee ,\wedge ,\top ,\rightarrow ,\leftrightarrow ,\subset$. (see validity)
* falsehood-preserving: The interpretation under which all variables are assigned a truth value of false produces a truth value of false as a result of these operations. E.g., $\vee ,\wedge ,\nleftrightarrow ,\bot ,\not \subset ,\not \supset$. (see validity)

### Arity

A concrete function may be also referred to as an operator. In two-valued logic there are 2 nullary operators (constants), 4 unary operators, 16 binary operators, 256 ternary operators, and $2^{2^{n}}$ n-ary operators. In three-valued logic there are 3 nullary operators (constants), 27 unary operators, 19683 binary operators, 7625597484987 ternary operators, and $3^{3^{n}}$ n-ary operators. In k-valued logic, there are k nullary operators, $k^{k}$ unary operators, $k^{k^{2}}$ binary operators, $k^{k^{3}}$ ternary operators, and $k^{k^{n}}$ n-ary operators. An n-ary operator in k-valued logic is a function from $\mathbb {Z} _{k}^{n}\to \mathbb {Z} _{k}$. Therefore, the number of such operators is $|\mathbb {Z} _{k}|^{|\mathbb {Z} _{k}^{n}|}=k^{k^{n}}$, which is how the above numbers were derived.
However, some of the operators of a particular arity are actually degenerate forms that perform a lower-arity operation on some of the inputs and ignore the rest of the inputs. Out of the 256 ternary Boolean operators cited above, ${\binom {3}{2}}\cdot 16-{\binom {3}{1}}\cdot 4+{\binom {3}{0}}\cdot 2$ of them are such degenerate forms of binary or lower-arity operators, using the inclusion–exclusion principle. The ternary operator $f(x,y,z)=\lnot x$ is one such operator which is actually a unary operator applied to one input, and ignoring the other two inputs.
"Not" is a unary operator, it takes a single term (¬P). The rest are binary operators, taking two terms to make a compound statement (P ∧ Q, P ∨ Q, P → Q, P ↔ Q).
The set of logical operators Ω may be partitioned into disjoint subsets as follows:
          $\Omega =\Omega _{0}\cup \Omega _{1}\cup \ldots \cup \Omega _{j}\cup \ldots \cup \Omega _{m}\,.$
In this partition, $\Omega _{j}$ is the set of operator symbols of arity j.
In the more familiar propositional calculi, $\Omega$ is typically partitioned as follows:
          nullary operators: $\Omega _{0}=\{\bot ,\top \}$
          unary operators: $\Omega _{1}=\{\lnot \}$
          binary operators: $\Omega _{2}\supset \{\land ,\lor ,\rightarrow ,\leftrightarrow \}$

## Principle of compositionality

Instead of using truth tables, logical connective symbols can be interpreted by means of an interpretation function and a functionally complete set of truth-functions (Gamut 1991), as detailed by the principle of compositionality of meaning. Let I be an interpretation function, let Φ, Ψ be any two sentences and let the truth function f$_{nand}$ be defined as:
* f$_{nand}$(T,T) = F; f$_{nand}$(T,F) = f$_{nand}$(F,T) = f$_{nand}$(F,F) = T
Then, for convenience, f$_{not}$, f$_{or}$ f$_{and}$ and so on are defined by means of f$_{nand}$:
* f$_{not}$(x) = f$_{nand}$(x,x)
* f$_{or}$(x,y) = f$_{nand}$(f$_{not}$(x), f$_{not}$(y))
* f$_{and}$(x,y) = f$_{not}$(f$_{nand}$(x,y))
or, alternatively f$_{not}$, f$_{or}$ f$_{and}$ and so on are defined directly:
* f$_{not}$(T) = F; f$_{not}$(F) = T;
* f$_{or}$(T,T) = f$_{or}$(T,F) = f$_{or}$(F,T) = T; f$_{or}$(F,F) = F
* f$_{and}$(T,T) = T; f$_{and}$(T,F) = f$_{and}$(F,T) = f$_{and}$(F,F) = F
Then
* I(~) = I($\neg$) = f$_{not}$
* I(&) = I($\wedge$) = f$_{and}$
* I(v) = I($\lor$) = f$_{or}$
* I(~Φ) = I($\neg$Φ) = I($\neg$)(I(Φ)) = f$_{not}$(I(Φ))
* I(Φ$\wedge$Ψ) = I($\wedge$)(I(Φ), I(Ψ)) = f$_{and}$(I(Φ), I(Ψ))
etc.
Thus if S is a sentence that is a string of symbols consisting of logical symbols v$_1$...v$_n$ representing logical connectives, and non-logical symbols c$_1$...c$_n$, then if and only if I(v$_1$)...I(v$_n$) have been provided interpreting v$_1$ to v$_n$ by means of f$_{nand}$ (or any other set of functional complete truth-functions) then the truth-value of ⁠$I(s)$⁠ is determined entirely by the truth-values of c$_1$...c$_n$, i.e. of I(c$_1$)...I(c$_n$). In other words, as expected and required, S is true or false only under an interpretation of all its non-logical symbols.

## Formal definition

Using the functions defined above, we can give a formal definition of a proposition's truth function.
Let PROP be the set of all propositional variables,
    $PROP=\{p_{1},p_{2},\dots \}$
We define a truth assignment to be any function $\phi :PROP\to \{T,F\}$. A truth assignment is therefore an association of each propositional variable with a particular truth value. This is effectively the same as a particular row of a proposition's truth table.
For a truth assignment, $\phi$, we define its extended truth assignment, ${\overline {\phi }}$, as follows. This extends $\phi$ to a new function ${\overline {\phi }}$ which has domain equal to the set of all propositional formulas. The range of ${\overline {\phi }}$ is still $\{T,F\}$.
* If $A\in PROP$ then ${\overline {\phi }}(A)=\phi (A)$.
* If A and B are any propositional formulas, then
** ${\overline {\phi }}(\neg A)=f_{\text{not}}({\overline {\phi }}(A))$.
** ${\overline {\phi }}(A\land B)=f_{\text{and}}({\overline {\phi }}(A),{\overline {\phi }}(B))$.
** ${\overline {\phi }}(A\lor B)=f_{\text{or}}({\overline {\phi }}(A),{\overline {\phi }}(B))$.
** ${\overline {\phi }}(A\to B)={\overline {\phi }}(\neg A\lor B)$.
** ${\overline {\phi }}(A\leftrightarrow B)={\overline {\phi }}((A\to B)\land (B\to A))$.
Finally, now that we have defined the extended truth assignment, we can use this to define the truth-function of a proposition. For a proposition, A, its truth function, $f_{A}$, has domain equal to the set of all truth assignments, and range equal to $\{T,F\}$.
It is defined, for each truth assignment $\phi$, by $f_{A}(\phi )={\overline {\phi }}(A)$. The value given by ${\overline {\phi }}(A)$ is the same as the one displayed in the final column of the truth table of A, on the row identified with $\phi$.

## Computer science

Logical operators are implemented as logic gates in digital circuits. Practically all digital circuits (the major exception is DRAM) are built up from NAND, NOR, NOT, and transmission gates. NAND and NOR gates with 3 or more inputs rather than the usual 2 inputs are fairly common, although they are logically equivalent to a cascade of 2-input gates. All other operators are implemented by breaking them down into a logically equivalent combination of 2 or more of the above logic gates.
The "logical equivalence" of "NAND alone", "NOR alone", and "NOT and AND" is similar to Turing equivalence.
The fact that all truth functions can be expressed with NOR alone is demonstrated by the Apollo guidance computer.