ArticleslgStudy

computer science

Three-valued logic

Three-valued logic is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Three-valued logic rather than just read about it. In short: A three-valued logic (also trinary logic, trivalent, ternary, or trilean, sometimes abbreviated 3VL) is any of several many-valued logic systems in which there are three truth values indicating true, false, and some third value. This is contrasted with the more commonly known bivalent logics (such as classical sentential or Boolean logic) which provide only for true and false.

Key takeaways

  • Three-valued logic belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Three-valued logic to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Three-valued logic from memory before moving on to harder problems.

Reference excerpt

A three-valued logic (also trinary logic, trivalent, ternary, or trilean, sometimes abbreviated 3VL) is any of several many-valued logic systems in which there are three truth values indicating true, false, and some third value. This is contrasted with the more commonly known bivalent logics (such as classical sentential or Boolean logic) which provide only for true and false. Emil Leon Post is credited with first introducing additional logical truth degrees in his 1921 theory of elementary propositions. The conceptual form and basic ideas of three-valued logic were initially published by Jan Łukasiewicz and Clarence Irving Lewis. These were then re-formulated by Grigore Constantin Moisil in an axiomatic algebraic form, and also extended to n-valued logics in 1945.

Pre-discovery Around 1910, Charles Sanders Peirce defined a many-valued logic system, but never published it. Peirce soundly rejected the idea that all propositions must be either true or false; boundary-propositions, he writes, are "at the limit between P and not P." However, as confident as he was that "Triadic Logic is universally true," he also jotted down that "All this is mighty close to nonsense." Only in 1966, when Max Fisch and Atwell Turquette began publishing what they rediscovered in his unpublished manuscripts, did Peirce's triadic ideas become widely known.

Motivation Broadly speaking, the primary motivation for research of three-valued logic is to represent the truth value of a statement that cannot be represented as true or false. Łukasiewicz initially developed three-valued logic for the problem of future contingents to represent the truth value of statements about the undetermined future. Bruno de Finetti used a third value to represent when "a given individual does not know the [correct] response, at least at a given moment." Hilary Putnam used it to represent values that cannot physically be decided:

For example, if we have verified (by using a speedometer) that the velocity of a motor car is such and such, it might be impossible in such a world to verify or falsify certain statements concerning its position at that moment. If we know by reference to a physical law together with certain observational data that a statement as to the position of a motor car can never be falsified or verified, then there may be some point to not regarding the statement as true or false, but regarding it as "middle". It is only because, in macrocosmic experience, everything that we regard as an empirically meaningful statement seems to be at least potentially verifiable or falsifiable that we prefer the convention according to which we say that every such statement is either true or false, but in many cases we don't know which. Similarly, Stephen Cole Kleene used a third value to represent predicates that are "undecidable by [any] algorithms whether true or false"

Representation of values As with bivalent logic, truth values in ternary logic may be represented numerically using various representations of the ternary numeral system. A few of the more common examples are:

in balanced ternary, each digit has one of 3 values: −1, 0, or +1; these values may also be simplified to −, 0, +, respectively; in the redundant binary representation, each digit can have a value of −1, 0, 0/1 (the value 0/1 has two different representations); in the ternary numeral system, each digit is a trit (trinary digit) having a value of: 0, 1, or 2; in the skew binary number system, only the least-significant non-zero digit can have a value of 2, and the remaining digits have a value of 0 or 1; 1 for true, 2 for false, and 0 for unknown, unknowable, undecidable, irrelevant, or both; 0 for false, 1 for true, and a third non-integer "maybe" symbol such as ?, #, ⁠1/2⁠, or xy. Inside a ternary computer, ternary values are represented by ternary signals. This article mainly illustrates a system of ternary propositional logic using the truth values {false, unknown, true}, and extends conventional Boolean connectives to a trivalent context.

Logics Boolean logic allows 22 = 4 unary operators; the addition of a third value with two inputs is 32 = 9 and with a third input in ternary logic leads to a total of 33 = 27 distinct operators on a single input set. (This may be made clear by considering all possible truth tables for an arbitrary unary operator. Given 2 possible values TF of the single Boolean input, there are four different patterns of output TT, TF, FT, FF resulting from the following unary operators acting on each value: always T, Identity, NOT, always F. Given three possible values of a ternary variable, each times three possible results of a unary operation, there are 27 different output patterns: TTT, TTU, TTF, TUT, TUU, TUF, TFT, TFU, TFF, UTT, UTU, UTF, UUT, UUU, UUF, UFT, UFU, UFF, FTT, FTU, FTF, FUT, FUU, FUF, FFT, FFU, and FFF.) Similarly, where Boolean logic has 22×2 = 16 distinct binary operators (operators with 2 inputs) possible, ternary logic has 33×3 = 19,683 such operators. While the nontrivial Boolean operators can be named ( NOT, AND, NAND, OR, NOR, XOR, XNOR (equivalence), and 4 variants of implication or inequality), with six trivial operators considering 0 or 1 inputs only, it is unreasonable to attempt to name all but a small fraction of the possible ternary operators. Just as in bivalent logic, where not all operators are given names and subsets of functionally complete operators are used, there may be functionally complete sets of ternary-valued operators.

Kleene and Priest logics

Below is a set of truth tables showing the logic operations for Stephen Cole Kleene's strong logic of indeterminacy and Graham Priest's logic of paradox.

If the truth values 1, 0, and −1 are interpreted as integers, these operations may be expressed with the ordinary operations of arithmetic (where x + y uses addition, xy uses multiplication, and x2 uses exponentiation), or by the minimum/maximum functions:

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with Three-valued logic

Start with the simplest possible case. Write down what Three-valued logic claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Three-valued logic before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Three-valued logic ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Three-valued logic

In research
Three-valued logic appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Three-valued logic in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Three-valued logic is common in secondary-school and first-year university syllabi. It links to neighbouring topics Many-valued logic, Ternary computers, so understanding it makes those chapters shorter.
In everyday life
Look for Three-valued logic outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Three-valued logic” →

How to study Three-valued logic in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Three-valued logic means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Three-valued logic out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Three-valued logic in simple terms?

A three-valued logic (also trinary logic, trivalent, ternary, or trilean, sometimes abbreviated 3VL) is any of several many-valued logic systems in which there are three truth values indicating true, false, and some third value. This is contrasted with the more commonly known bivalent logics (such…

Why does Three-valued logic matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Three-valued logic?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Three-valued logic.

Tags

  • Many-valued logic
  • Ternary computers

Keep exploring