Truth function
In logic, a truth function[1] is a function that accepts truth values as input and produces a truth value as output, i.e., the input and output are all truth values. The typical example is in propositional logic, wherein a compound statement is constructed by one or two statements connected by a logical connective; if the truth value of the compound statement is determined by the truth value(s) of the constituent statement(s), the compound statement is called a truth function, and the logical connective is said to be truth functional.[2]
Classical propositional logic is a truthfunctional propositional logic,[3] 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.[4] On the contrary, modal logic is nontruthfunctional.
Overview
A logical connective is truthfunctional if the truthvalue of a compound sentence is a function of the truthvalue of its subsentences. A class of connectives is truthfunctional if each of its members is. For example, the connective "and" is truthfunctional since a sentence like "Apples are fruits and carrots are vegetables" is true if, and only if each of its subsentences "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 truthfunctional.
Connectives of the form "x believes that ..." are typical examples of connectives that are not truthfunctional. 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 truthvalue. That is, the truthvalue of a sentence of the form "Mary believes that..." is not determined solely by the truthvalue of its component sentence, and hence the (unary) connective (or simply operator since it is unary) is nontruthfunctional.
The class of classical logic connectives (e.g. &, →) used in the construction of formulas is truthfunctional. Their values for various truthvalues as argument are usually given by truth tables. Truthfunctional propositional calculus is a formal system whose formulae may be interpreted as either true or false.
Table of binary truth functions
In twovalued 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 is denoted as 1 and 0 in the following truth tables, respectively, for sake of brevity.

 

 

 

 

 

 

 


Functional completeness
Because a function may be expressed as a composition, a truthfunctional logical calculus does not need to have dedicated symbols for all of the abovementioned 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 classicalbased 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:[5]
 One element
 {↑}, {↓}.
 Two elements
 , , , , , , , , , , , , , , , , , .
 Three elements
 , , , , , .
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 truthvalue 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 truthpreserving and falsehoodpreserving (see below).
 absorption: A pair of connectives satisfies the absorption law if 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., .
 affine: For each variable, changing its value either always or never changes the truthvalue of the operation, for all fixed values of all other variables. E.g., , .
 self dual: To read the truthvalue 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., .
 truthpreserving: 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., . (see validity)
 falsehoodpreserving: 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., . (see validity)
Arity
A concrete function may be also referred to as an operator. In twovalued logic there are 2 nullary operators (constants), 4 unary operators, 16 binary operators, 256 ternary operators, and nary operators. In threevalued logic there are 3 nullary operators (constants), 27 unary operators, 19683 binary operators, 7625597484987 ternary operators, and nary operators. In kvalued logic, there are k nullary operators, unary operators, binary operators, ternary operators, and nary operators. An nary operator in kvalued logic is a function from . Therefore, the number of such operators is , which is how the above numbers were derived.
However, some of the operators of a particular arity are actually degenerate forms that perform a lowerarity operation on some of the inputs and ignores the rest of the inputs. Out of the 256 ternary boolean operators cited above, of them are such degenerate forms of binary or lowerarity operators, using the inclusion–exclusion principle. The ternary operator 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:
In this partition, is the set of operator symbols of arity j.
In the more familiar propositional calculi, is typically partitioned as follows:
 nullary operators:
 unary operators:
 binary operators:
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 truthfunctions (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() = f_{not}
 I(&) = I() = f_{and}
 I(v) = I() = f_{or}
 I(~Φ) = I(Φ) = I()(I(Φ)) = f_{not}(I(Φ))
 I(ΦΨ) = I()(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 nonlogical 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 truthfunctions) then the truthvalue of is determined entirely by the truthvalues 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 nonlogical symbols.
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 2input 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.
See also
Notes
 Roy T. Cook (2009). A Dictionary of Philosophical Logic, p. 294: Truth Function. Edinburgh University Press.
 Roy T. Cook (2009). A Dictionary of Philosophical Logic, p. 295: Truth Functional. Edinburgh University Press.
 Internet Encyclopedia of Philosophy: Propositional Logic, by Kevin C. Klement
 Roy T. Cook (2009). A Dictionary of Philosophical Logic, p. 47: Classical Logic. Edinburgh University Press.
 Wernick, William (1942) "Complete Sets of Logical Functions," Transactions of the American Mathematical Society 51: 117–32. In his list on the last page of the article, Wernick does not distinguish between ← and →, or between and .
References
 This article incorporates material from TruthFunction on PlanetMath, which is licensed under the Creative Commons Attribution/ShareAlike License.
Further reading
 Józef Maria Bocheński (1959), A Précis of Mathematical Logic, translated from the French and German versions by Otto Bird, Dordrecht, South Holland: D. Reidel.
 Alonzo Church (1944), Introduction to Mathematical Logic, Princeton, NJ: Princeton University Press. See the Introduction for a history of the truth function concept.