Online Encyclopedia
Ternary logic
Ternary logic is a multi-valued logic in which there are three states, thus the ternary numeral system is used to represent ternary logic equations. This article is a work in progress.
Contents |
|
Formal definitions
Significations
In ternary logic, the number symbols have the following meaning:
- 0 means true or false
- 1 means true
- 2 means false
(This is different from base-3 Ternary numerals, where 0, 1, and 2 mean the same thing they do in decimal).
Ternary operators
Inversion (NOT)
- NOT(0) = 0
- NOT(1) = 2
- NOT(2) = 1
Conjunction (AND), Disjunction (OR), Implication (IF...THEN), and Equivalence (EQUALS)
x | y | Conjunctive (X Y) | Disjunctive (X Y) | Implication (X → Y) | Equivalence (X ↔ Y) |
---|---|---|---|---|---|
0 | 0 | 0 | 0 | 1 | 1 |
0 | 1 | 0 | 1 | 1 | 0 |
0 | 2 | 2 | 0 | 0 | 0 |
1 | 0 | 0 | 1 | 0 | 0 |
1 | 1 | 1 | 1 | 1 | 1 |
1 | 2 | 2 | 1 | 2 | 2 |
2 | 0 | 2 | 0 | 1 | 0 |
2 | 1 | 2 | 1 | 1 | 2 |
2 | 2 | 2 | 2 | 1 | 1 |
Other operators
All other ternary logic operators can be simulated by the four basic operators NOT, AND, OR and IF...THEN.
The 27 one-variable functions in ternary logic are represented in the following table.
f1 | f2 | f3 | f4 | f5 | f6 | f7 | "1" | f9 | f10 | f11 | "0" | f13 | f14 | f15 | f16 | f17 | f18 | f19 | NOT | f21 | "2" | f23 | f24 | f25 | f26 | f27 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0 | 0 | 0 | 2 | 2 | 2 | 1 | 1 | 1 | 0 | 0 | 0 | 2 | 2 | 2 | 1 | 1 | 1 | 0 | 0 | 0 | 2 | 2 | 2 | 1 | 1 | 1 |
1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 | 2 |
2 | 2 | 1 | 0 | 2 | 1 | 0 | 2 | 1 | 0 | 2 | 1 | 0 | 2 | 1 | 0 | 2 | 1 | 0 | 2 | 1 | 0 | 2 | 1 | 0 | 2 | 1 | 0 |
The number of functions for a given number of variables for trinary logic can be calculated by the equation , where v represents the number of variables. This gives us
- 27 one-variable functions in ternary logic (as compared to only 4 one-variable Boolean functions).
- 19,683 two-variable functions in trinary logic (compared with 16 for binary), and
- 7,625,597,484,987 three-variable functions.
Ternary logic in philosophy
Trits, tribbles, and trytes
Basic Ternary Algebra: Unary Functions
Constant functions
000 clear to 0 111 clear to 1 222 clear to 2
One-to-one functions
This might look better in tables and the symbols might look better in TeX.
F# Name Diff:012 Inverse Expression 012 buffer ''' 012 A A 021 swap 1/2 '/\ 021 ['A ∪A 102 swap 0/1 /\' 102 ]'A ∩A 120 rotate up /// 201 ]A ∩A 201 rotate down \\\ 120 [A ∪A 210 swap 0/2 \'/ 210 'A A, or A'
Many-to-one functions
F# ITE Expression 001 210 \A ↘A Shift Down 002 220 ]/'A ∩↗A 010 100 \]A ↘∩A 011 001 \/A ↘↗A 020 120 ]/['A ∩↗∪A 022 002 [\'A ∪↘A 100 010 \'A ↘A 101 101 [/['A ∪↗∪A 110 210 [/'A ∪↗A 112 221 /\A ↗↘A 121 121 ]\]A ∩↘∩A 122 012 /A ↗A Shift Up 200 020 ]/A ∩↗A 202 102 [\]A ∪↘∩A 211 021 ]\'A ∩↘A 212 112 /['A ↗∪A 220 202 [\A ∪↘A 221 212 /'A ↗A
Binary functions
Commutativity
Preference functions
Tritmasks
Named functions
Advanced functions
Unbalanced arithmetic
Negation: 3's complement
Addition / subtraction
Balanced arithmetic
Negation: inversion
Addition / subtraction
Unknown-state logic
Implementation
Existing computers
Magnetism
Electromechanical relays
Rapid single flux quantum
Rectifiers
External links
- Steve Grub's Trinary.cc http://www.trinary.cc/
- Trinary Computer Systems http://xyzzy.freeshell.org/trinary/
- TriINTERCAL http://www.progsoc.uts.edu.au/~sbg/intercal/ick5.html
- Trivalent Logic in the Language of Aymara http://www.aymara.org/biblio/igr/igr3.html
- A brief introduction to ternary logic http://www.aymara.org/ternary/ternary.pdf
See also: Digital circuit, Ternary, Boolean algebra, Boolean function, binary logic.