Ternary logic
Encyclopedia
In logic
Logic
In philosophy, Logic is the formal systematic study of the principles of valid inference and correct reasoning. Logic is used in most intellectual activities, but is studied primarily in the disciplines of philosophy, mathematics, semantics, and computer science...

, a three-valued logic (also trivalent, ternary, or trinary logic, sometimes abbreviated 3VL) is any of several many-valued logic systems in which there are three truth values indicating true, false and some indeterminate third value. This is contrasted with the more commonly known bivalent
Principle of bivalence
In logic, the semantic principle of bivalence states that every declarative sentence expressing a proposition has exactly one truth value, either true or false...

 logics (such as classical sentential or boolean logic
Boolean logic
Boolean algebra is a logical calculus of truth values, developed by George Boole in the 1840s. It resembles the algebra of real numbers, but with the numeric operations of multiplication xy, addition x + y, and negation −x replaced by the respective logical operations of...

) which provide only for true and false. Conceptual form and basic ideas were initially created by Łukasiewicz, Lewis  and Sulski. These were then re-formulated by Grigore Moisil
Grigore Moisil
Grigore Constantin Moisil was a Romanian mathematician, computer pioneer, and member of the Romanian Academy. His research was mainly in the fields of mathematical logic, , Algebraic logic, MV-algebra, algebra and differential equations...

 in an axiomatic algebraic form, and also extended to n-valued logics in 1945.

Representation of values

As with bivalent logic, truth values in ternary logic may be represented numerically using various representations of the ternary numeral system
Ternary numeral system
Ternary is the base- numeral system. Analogous to a bit, a ternary digit is a trit . One trit contains \log_2 3 bits of information...

. A few of the more common examples are:
  • 1 for true, 2 for false, and 0 for unknown, irrelevant, or both.
  • 0 for false, 1 for true, and a third non-integer symbol such as # or ½ for the final value.
  • Balanced ternary
    Balanced ternary
    Balanced ternary is a non-standard positional numeral system , useful for comparison logic. It is a ternary system, but unlike the standard ternary system, the digits have the values −1, 0, and 1...

     uses −1 for false, +1 for true and 0 for the third value; these values may also be simplified to −, +, and 0, respectively.


This article mainly illustrates a system of ternary propositional logic using the truth values {false, unknown, and true}, and extends conventional boolean connectives to a trivalent context. Ternary predicate logic
Predicate logic
In mathematical logic, predicate logic is the generic term for symbolic formal systems like first-order logic, second-order logic, many-sorted logic or infinitary logic. This formal system is distinguished from other systems in that its formulae contain variables which can be quantified...

s exist as well; these may have readings of the quantifier different from classical (binary) predicate logic, and may include alternative quantifiers as well.

Kleene logic

Below is a set of truth table
Truth table
A truth table is a mathematical table used in logic—specifically in connection with Boolean algebra, boolean functions, and propositional calculus—to compute the functional values of logical expressions on each of their functional arguments, that is, on each combination of values taken by their...

s showing the logic operations for Kleene
Stephen Cole Kleene
Stephen Cole Kleene was an American mathematician who helped lay the foundations for theoretical computer science...

's logic.
! A AND B !! True !! False !! Unknown
|-
! scope="row" | True>
True False >- False False False >- Unknown Unknown False Unknown

! A OR B !! True !! False !! Unknown
|-
! scope="row" | True >
True True >- False True False >- Unknown True Unknown Unknown

! A !! NOT A
|-
! scope="row" | True >
>- False >- Unknown Unknown

In this truth table, 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 are assigned to FALSE, UNKNOWN and TRUE such that FALSE

Computer science

The database structural query language, SQL
SQL
SQL is a programming language designed for managing data in relational database management systems ....

, implements ternary logic as a means of handling NULL
Null (SQL)
Null is a special marker used in Structured Query Language to indicate that a data value does not exist in the database. Introduced by the creator of the relational database model, E. F. Codd, SQL Null serves to fulfill the requirement that all true relational database management systems support...

 field content. SQL uses NULL to represent missing data in a database. If a field contains no defined value, SQL assumes this means that an actual value exists, but that the value is not currently recorded in the database. Note that a missing value is not the same as either a numeric value of zero, or a string value of zero length. Comparing anything to NULL—even another NULL—results in an UNKNOWN truth state. For example, the SQL expression "City = 'Paris'" resolves to FALSE for a record with "Chicago" in the City field, but it resolves to UNKNOWN for a record with a NULL City field. In other words, to SQL, an undefined field represents potentially any possible value: a missing city might or might not represent Paris.

Using ternary logic, SQL can then account for the UNKNOWN truth state in evaluating boolean expressions. Consider the expression "City = 'Paris' OR Balance < 0.0". This expression resolves to TRUE for any record whose Balance field contains a negative number. Likewise, this expression is TRUE for any record with 'Paris' in its City field. The expression resolves to FALSE only for a record whose City field explicitly contains a string other than 'Paris', and whose Balance field explicitly contains a non-negative number. In any other case, the expression resolves to UNKNOWN. This is because a missing City value might be missing the string 'Paris', and a missing Balance might be missing a negative number. However, regardless of missing data, a boolean OR operation is FALSE only when both of its operands are also FALSE, so not all missing data leads to an UNKNOWN resolution.

In SQL Data Manipulation Language
Data Manipulation Language
A data manipulation language is a family of syntax elements similar to a computer programming language used for inserting, deleting and updating data in a database...

, a truth state of TRUE for an expression (e.g., in a WHERE clause) initiates an action on a row (e.g. return the row), while a truth state of UNKNOWN or FALSE does not. In this way, ternary logic is implemented in SQL, while behaving as binary logic to the SQL user.

SQL Check Constraint
Check Constraint
A check constraint is a condition that defines valid data when adding or updating an entry in a table of a relational database. A check constraint is applied to each row in the table. The constraint must be a predicate. It can refer to a single or multiple columns of the table...

s behave differently, however. Only a truth state of FALSE results in a violation of a check constraint. A truth state of TRUE or UNKNOWN indicates a row has been successfully validated against the check constraint.

See also

  • Digital circuit
    Digital circuit
    Digital electronics represent signals by discrete bands of analog levels, rather than by a continuous range. All levels within a band represent the same signal state...

  • Ternary numeral system
    Ternary numeral system
    Ternary is the base- numeral system. Analogous to a bit, a ternary digit is a trit . One trit contains \log_2 3 bits of information...

     (and Balanced ternary
    Balanced ternary
    Balanced ternary is a non-standard positional numeral system , useful for comparison logic. It is a ternary system, but unlike the standard ternary system, the digits have the values −1, 0, and 1...

    )
  • Ternary computer
    Ternary computer
    A ternary computer is a computer that uses ternary logic instead of the more common binary logic in its calculations.-History:...

  • Boolean algebra (structure)
  • Boolean function
  • Binary logic
    Binary logic
    Binary logic could refer to:* any two-valued logic, especially in social sciences* classical propositional two-valued logic, also called boolean logic in engineering, which is the logical foundation of digital electronics...

  • Setun
    Setun
    Setun was a balanced ternary computer developed in 1958 at Moscow State University. The device was built under the lead of Sergei Sobolev and Nikolay Brusentsov. It was the only modern ternary computer, using three-valued ternary logic instead of two-valued binary logic prevalent in computers...

     - an experimental Russian computer which was based on ternary logic
  • Aymara language
    Aymara language
    Aymara is an Aymaran language spoken by the Aymara people of the Andes. It is one of only a handful of Native American languages with over three million speakers. Aymara, along with Quechua and Spanish, is an official language of Peru and Bolivia...

     - a Bolivian language famous for using ternary rather than binary logic
  • Four value logic
  • Null (SQL)
    Null (SQL)
    Null is a special marker used in Structured Query Language to indicate that a data value does not exist in the database. Introduced by the creator of the relational database model, E. F. Codd, SQL Null serves to fulfill the requirement that all true relational database management systems support...

    - SQL database query language incorporates NULL marker as part of its ternary logic implementation
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK