# Three-valued logic

{{ safesubst:#invoke:Unsubst||$N=Refimprove |date=__DATE__ |$B= {{#invoke:Message box|ambox}} }}

## Logics

Where Boolean Logic has 4 monadic operators, the addition of a third value in ternary logic leads to a total of 27 distinct operators on a single input value. Similarly, where Boolean logic has 16 distinct diadic operators (operators with 2 inputs), ternary logic has 19,683 such operators. Where we can easily name a significant fraction of the Boolean operators (not, and, or, nand, nor, exclusive or), it is unreasonable to attempt to name all but a small fraction of the possible ternary operators.[4]

### Kleene logic

{{#invoke:see also|seealso}} Below is a set of truth tables showing the logic operations for Kleene's logic.

(F: FALSE, U: UNKNOWN, T: TRUE)
NOT(A)
A ¬ A
F T
U U
T F
AND(A, B)
AB B
F U T
A F F F F
U F U U
T F U T
OR(A, B)
AB B
F U T
A F F U T
U U U T
T T T T
(−1: FALSE, 0: UNKNOWN, +1: TRUE)
NEG(A)
A ¬ A
−1 +1
0 0
+1 −1
MIN(A, B)
AB B
−1 0 +1
A −1 −1 −1 −1
0 −1 0 0
+1 −1 0 +1
MAX(A, B)
AB B
−1 0 +1
A −1 −1 0 +1
0 0 0 +1
+1 +1 +1 +1

In these truth tables, the UNKNOWN state can be metaphorically thought of as a sealed box containing either an unambiguously TRUE or unambiguously FALSE value. The knowledge of whether any particular UNKNOWN state secretly represents TRUE or FALSE at any moment in time is not available. However, certain logical operations can yield an unambiguous result, even if they involve at least one UNKNOWN operand. For example, since TRUE OR TRUE equals TRUE, and TRUE OR FALSE also equals TRUE, one can infer that TRUE OR UNKNOWN equals TRUE, as well. In this example, since either bivalent state could be underlying the UNKNOWN state, but either state also yields the same result, a definitive TRUE results in all three cases.

If numeric values, e.g. balanced ternary values, are assigned to FALSE, UNKNOWN and TRUE such that FALSE is less than UNKNOWN and UNKNOWN is less than TRUE, then A AND B AND C... = MIN(A, B, C ...) and A OR B OR C ... = MAX(A, B, C...).

Material implication for Kleene logic can be defined as:

IMPK(A, B), OR(¬A, B)
A B B
T U F
A T T U F
U T U U
F T T T
IMPK(A, B), MAX(−A, B)
A B B
+1 0 −1
A +1 +1 0 −1
0 +1 0 0
−1 +1 +1 +1

which differs from that for Łukasiewicz logic (described below).

Kleene logic has no tautologies (valid formulas) because whenever all of the atomic components of a well-formed formula are assigned the value Unknown, the formula itself must also have the value Unknown. (And the only designated truth value for Kleene logic is True.) However, the lack of valid formulas does not mean that it lacks valid arguments and/or inference rules. An argument is semantically valid in Kleene logic if, whenever (for any interpretation/model) all of its premises are True, the conclusion must also be True. (Note that the Logic of Paradox (LP) has the same truth tables as Kleene logic, but it has two designated truth values instead of one; these are: True and Both (the analogue of Unknown), so that LP does have tautologies but it has fewer valid inference rules.)[5]

### Łukasiewicz logic

Template:Rellink The Łukasiewicz Ł3 has the same tables for AND, OR, and NOT as the Kleene logic given above, but differs in its definition of implication. This section follows the presentation from Malinowski's chapter of the Handbook of the History of Logic, vol 8.[6]

IMPŁ(A, B)
A B B
T U F
A T T U F
U T T U
F T T T
IMPŁ(A, B)
A B B
+1 0 −1
A +1 +1 0 −1
0 +1 +1 0
−1 +1 +1 +1

In fact, using Łukasiewicz's implication and negation, the other usual connectives may be derived as:

• AB = (AB) → B
• AB = ¬(¬A ∨ ¬ B)
• AB = (AB) ∧ (BA)

It's also possible to derive a few other useful unary operators (first derived by Tarski in 1921):

• MA = ¬AA
• LA = ¬M¬A
• IA = MA ∧ ¬LA

They have the following truth tables:

A MA
F F
U T
T T
A LA
F F
U F
T T
A IA
F F
U T
T F

M is read as "it is not false that..." or in the (unsuccessful) Tarski–Łukasiewicz attempt to axiomatize modal logic using a three-valued logic, "it is possible that..." L is read "it is true that..." or "it is necessary that..." Finally I is read "it is unknown that..." or "it is contingent that..."

In Łukasiewicz's Ł3 the designated value is True, meaning that only a proposition having this value everywhere is considered a tautology. For example AA and AA are tautologies in Ł3 and also in classical logic. Not all tautologies of classical logic lift to Ł3 "as is". For example, the law of excluded middle, A ∨ ¬A, and the law of non-contradiction, ¬(A ∧ ¬A) are not tautologies in Ł3. However, using the operator I defined above, it is possible to state tautologies that are their analogues:

• AIA ∨ ¬A [law of excluded fourth]
• ¬(A ∧ ¬IA ∧ ¬A) [extended contradiction principle].

### Bochvar logic

{{#invoke:main|main}} Template:Empty section

### Modular algebras

Some 3VL modular algebras have been introduced more recently, motivated by circuit problems rather than philosophical issues:[7]

• Cohn algebra
• Dubrova and Muzio algebra

## Application in SQL

{{#invoke:main|main}} The database structural query language SQL implements ternary logic as a means of handling comparisons with NULL field content. The original intent of NULL in SQL was to represent missing data in a database, i.e. the assumption that an actual value exists, but that the value is not currently recorded in the database. SQL uses a common fragment of the Kleene K3 logic, restricted to AND, OR, and NOT tables. In SQL, the intermediate value is intended to be interpreted as UNKNOWN. Explicit comparisons with NULL, including that of another NULL yields UNKNOWN. However this choice of semantics is abandoned for some set operations, e.g. UNION or INTERSECT, where NULLs are treated as equal with each other. Critics assert that this inconsistency deprives SQL of intuitive semantics in its treatment of NULLs.[8] The SQL standard defines an optional feature called F571, which adds some unary operators, among which IS UNKNOWN corresponding to the Łukasiewicz I in this article. The addition of IS UNKNOWN to the other operators of SQL's three-valued logic makes the SQL three-valued logic functionally complete,[9] meaning its logical operators can express (in combination) any conceivable three-valued logical function.

## References

1. {{#invoke:citation/CS1|citation |CitationClass=book }}
2. {{#invoke:Citation/CS1|citation |CitationClass=journal }}
3. {{#invoke:citation/CS1|citation |CitationClass=book }}
4. Douglas W. Jones, Standard Ternary Logic, Feb. 11, 2013
5. http://www.uky.edu/~look/Phi520-Lecture7.pdf
6. Grzegorz Malinowski, "Many-valued Logic and its Philosophy" in Dov M. Gabbay, John Woods (eds.) Handbook of the History of Logic Volume 8. The Many Valued and Nonmonotonic Turn in Logic, Elsevier, 2009
7. {{#invoke:citation/CS1|citation |CitationClass=book }}
8. Ron van der Meyden, "Logical approaches to incomplete information: a survey" in Chomicki, Jan; Saake, Gunter (Eds.) Logics for Databases and Information Systems, Kluwer Academic Publishers ISBN 978-0-7923-8129-7, p. 344; PS preprint (note: page numbering differs in preprint from the published version)
9. C. J. Date, Relational database writings, 1991-1994, Addison-Wesley, 1995, p. 371
10. Template:Cite web