Truth function
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 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 of the constituent statement, 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, 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
is true while
is false. In both cases, each component sentence 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 connective is non-truth-functional.
The class of classical logic connectives 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 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 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 equivalent to. The conditional operator "→" is therefore not necessary for a classical-based logical system if "¬" and "∨" 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:
;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 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 · = + 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.
- absorption: A pair of connectives satisfies the absorption law if for all operands a, b.
- monotonic: If f ≤ f for all a1,..., an, b1,..., bn ∈ such that a1 ≤ b1, a2 ≤ b2,..., an ≤ bn. E.g.,.
- 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.,, .
- 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 = ¬f. E.g.,.
- 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.,.
- 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.,.
Arity
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 ignores the rest of the inputs. Out of the 256 ternary boolean operators cited above, of them are such degenerate forms of binary or lower-arity 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. The rest are binary operators, taking two terms to make a compound statement.
The set of logical operators may be partitioned into disjoint subsets as follows:
In this partition, is the set of operator symbols of arity.
In the more familiar propositional calculi, is typically partitioned as follows:
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, 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 fnand be defined as:
- fnand = F; fnand = fnand = fnand = T
- fnot = fnand
- for = fnand, fnot)
- fand = fnot
- fnot = F; fnot = T;
- for = for = for = T; for = F
- fand = T; fand = fand = fand = F
etc.
Thus if S is a sentence that is a string of symbols consisting of logical symbols v1...vn representing logical connectives, and non-logical symbols c1...cn, then if and only if have been provided interpreting v1 to vn by means of fnand then the truth-value of is determined entirely by the truth-values of c1...cn, i.e. of. In other words, as expected and required, S is true or false only under an interpretation of all its non-logical symbols.
Computer science
Logical operators are implemented as logic gates in digital circuits. Practically all digital circuits 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.