# 三值逻辑

## 定义

### 基本真值表

A B AB AB ¬ A
True True True True False
True Unknown True Unknown False
True False True False False
Unknown True True Unknown Unknown
Unknown Unknown Unknown Unknown Unknown
Unknown False Unknown False Unknown
False True True False True
False Unknown Unknown False True
False False False False True

### 值的表示

• 1用于真，2用于假，0用于“未知”、“无关”或“二者”。[1]
• 0用于假，1用于真，第三值使用非整数符号比如# 或½。[2]
• 平衡三进制：= -1用于假，1用于真，0用于第三值；这些值还可以分别简化为 -、+和0。[3]

## 在数据库应用中的三值逻辑

`City = 'Paris'`

• 对于在City字段中有文字串'Paris'的任何记录结果为TRUE
• 对于在City字段中有NULL的任何记录结果为UNKNOWN
• 在所有其他情况结果为FALSE

## 引用

1. ^ Hayes, Brian. Third Base. American Scientist (Sigma Xi, the Scientific Research Society). November-December, 2001, 89 (6): 490–494 [2006-12-25].
2. ^ The Penguin Dictionary of Mathematics. 2nd Edition. London, England: Penguin Books. 1998: 417.
3. ^ Knuth, Donald E.. The Art of Computer Programming Vol. 2. Reading, Mass.: Addison-Wesley Publishing Company. 1981: 190.
4. ^ Lex de Haan and Gennick, Jonathan. Nulls: Nothing to Worry About. Oracle Magazine (Oracle). July-August, 2005.
5. ^ Coles, Michael. Null Versus Null?. SQL Server Central (Red Gate Software). February 26, 2007.

## 外部链接

• Trinary Computer Systems
• TriINTERCAL - the intentionally-obfuscated INTERCAL programming language supports an implementation of ternary logic
• Boost.Tribool – an implementation of ternary logic in C++
• Team-R2D2 - a French institute that fabricated the first full-ternary logic chip (a 64-tert SRAM and 4-tert adder) in 2004