Three-valued Logic

Also known as: Kleene logic, unknown value, NULL logic.

Logic with a third value, unknown, besides true and false. A rule that depends on a missing value is unknown, not false.

Synthetic dataExamples on this page use synthetic data created for illustration.

Definition

Three-valued logic adds a third truth value, unknown, to true and false. A rule that depends on a missing value gives unknown rather than false, and combining values follows fixed tables: true AND unknown is unknown, while false AND unknown is false.

In plain terms

Databases use this logic for NULL, and rule-based scoring needs it for the same reason: when a fact is missing, “we do not know” is a different answer from “no”. If unknown is silently treated as false, items with incomplete data disappear from results with no trace.

The combination rules are intuitive once stated. An AND is false as soon as one part is false, true only if all are true, and otherwise unknown. An OR is true as soon as one part is true, false only if all are false, and otherwise unknown. NOT of unknown is unknown.

Example

Rule: price below 20 AND in stock. An item costs 15, and its stock status is not recorded.

PartValue
price below 20true
in stockunknown
Both (true AND unknown)unknown
ABA AND BA OR B
trueunknownunknowntrue
falseunknownfalseunknown
unknownunknownunknownunknown

A two-valued system would turn “unknown” into “false” and drop the item. A three-valued system can report it as “possible match, stock unknown”.

Common misunderstandings

  • “Unknown is the same as false.” It is a separate outcome that deserves its own handling.
  • “NULL = NULL is true.” In SQL it is unknown, because two unknowns are not known to be equal.
  • “Missing values only matter for the data team.” They change which items a rule includes, so they change the results users see.

References

  1. Logical Operators (PostgreSQL documentation, section 9.1) . The PostgreSQL Global Development Group.
  2. E. F. Codd. Missing Information (Applicable and Inapplicable) in Relational Databases . ACM SIGMOD Record, 1986. DOI: 10.1145/16301.16303