Computers think in zeros and ones. But what if that’s not enough to describe reality? In this video, we take a look at three-valued logic — a system that introduces a third truth value: unknown.
It’s a concept that challenges centuries of binary thinking, from Aristotle’s Law of the Excluded Middle to George Boole’s algebra that became the foundation of every modern CPU.
Polish mathematician Jan Łukasiewicz was among the first to formalize this idea, introducing a logic that could handle uncertainty — statements that are not yet true, nor false.
Decades later, his ideas were used by Soviet engineers to build Setun, the world’s first ternary computer.
This video dives into the history, mathematics, and modern relevance of ternary logic — from Aristotle to Łukasiewicz, from Boolean circuits to SQL queries — and why this forgotten idea might still shape the future of computing.
*https://www.youtube.com/watch?v=NB9nGzd_atA
**https://300.ya.ru/v_aHanaOui
таймкоды
00:00:00 Введение в парадокс кота Шрёдингера
- Кот Шрёдингера иллюстрирует парадокс квантовой механики: кот может быть и живым, и мёртвым одновременно.
- В компьютерной логике решения обычно принимаются в двоичном формате: «истина» или «ложь».
- Бинарная логика не всегда отражает сложность реальных ситуаций.
00:00:53 Троичная логика и её потенциал
- Троичная логика может быть более подходящей для обработки неопределённых ситуаций.
- Троичные компьютеры могут стать важным шагом в развитии вычислительной техники.
- Программисты могут использовать логику со свободными значениями даже не осознавая этого.
00:01:19 Булева алгебра и её операторы
- Джордж Булл описал булеву алгебру, используя истинные или ложные утверждения как алгебраические символы.
- Основные операторы: отрицание, конъюнкция и дизъюнкция.
- Эти операторы позволяют создавать системы, выполняющие арифметические действия с двоичными данными.
00:02:49 Закон исключённого среднего и его ограничения
- Закон исключённого среднего утверждает, что каждое утверждение должно быть истинным или ложным.
- Утверждения о будущем, такие как «завтра состоится морское сражение», нарушают этот закон.
- Ян Лукашевич предложил логику со свободными значениями для решения этой проблемы.
00:04:09 Логика со свободными значениями
- Лукашевич ввёл логику со свободными значениями, где пропозиция может быть истинной, ложной или возможной.
- Третье значение позволяет обрабатывать неопределённые случаи, такие как утверждения о будущем.
- В троичной системе счисления минус один соответствует ложному, ноль — неизвестному, а плюс один — истинному.
00:05:16 Основные операторы троичной логики
- Лукашевич определил три основных оператора: отрицание, дизъюнкция и конъюнкция.
- Отрицание инвертирует значение переменной.
- Конъюнкция соответствует минимальной функции, а дизъюнкция — максимальной функции.
00:06:25 Функциональная завершённость
- В троичной логике существует 19 683 различных оператора, но на практике используется только подмножество функционально завершённых операторов.
- Функциональная завершённость позволяет создавать все остальные операторы из ограниченного набора базовых.
00:09:01 Практическое применение троичной логики
- Троичная логика находит применение в SQL при работе с нулевыми значениями.
- В SQL логические операторы действуют аналогично троичной логике, обрабатывая null как неизвестное значение.
- Это позволяет избежать неверных результатов при обработке отсутствующей информации.
00:10:17 Логика со свободными значениями
- Запросы могут отображать фактическое состояние знаний, включая недоступность данных.
- Бинарная логика часто вынуждает принимать решения «да» или «нет» преждевременно.
- Логика со свободными значениями лучше представляет реальность, которая часто включает неопределённые состояния.
In this video
Schrödinger’s Cat and Binary Thinking
0:00
You might have heard about the Schrödinger’s cat.
0:02
To summarize it very briefly, it’s a paradox in which, due
0:05
to quantum mechanics,
0:06
a cat inside a box could be both dead and alive at the same time.
0:11
This thought experiment is confusing on its own,
0:13
but probably even more so to computer scientists.
0:16
Let me explain.
0:17
When we think
0:17
about computers, more specifically about computer logic, we think in binary.
0:22
At its core, every decision a machine makes leads to a true
0:25
or false conclusion — a zero or a one.
0:28
Binary logic is so deeply ingrained in modern technology
0:31
that it feels inevitable, almost natural.
0:35
But binary is not the only way to build logic.
0:38
In fact, there is a strong case to be made that two values
0:41
don’t always capture the complexity of certain situations, like
0:46
in the case of the aforementioned cat.
0:48
Sometimes a system needs a third option- not yes or no, but maybe.
0:53
A few weeks ago I made a video about the base 3 number system.
0:57
In the comments a lot of you were asking for a deeper dive into ternary.
1:00
That’s why in this video I’d like to focus specifically
1:03
on ternary logic, which makes ternary computers feasible.
1:07
It’s a fascinating concept that could be just as important
1:10
to the future of computing as binary logic has been to its best.
1:14
And if you were a programmer,
1:15
you might have already used free valued logic without knowing it.
1:19
I’ll expand on that later in the video.
1:21
Welcome to Codeolences, my name is Jakub and if you are interested in alternative,
1:25
little known computer technologies, you are in the right place.
1:29
There are more videos like this coming your way
1:31
so make sure to subscribe to not miss them.
The Basics of Digital Logic
1:33
In the 19th century, English mathematician George Boole described the concept
1:37
we know as Boolean algebra.
1:39
His insight was that true or false statements could be treated
1:42
like algebraic symbols and manipulated with basic operators.
1:46
Boole define three fundamental functions.
1:49
Negation inverts the value of the variable.
1:51
If x is equal to one, then negated x is zero.
1:55
If x is zero, then the gate at x is one.
1:58
Conjunction is a two variable operator that yields
2:01
one only if both variables x and y are equal to one.
2:05
If either of them is zero, the result is also zero.
2:08
This is the end operator.
2:10
Finally, both define the disjunction.
2:12
It yields one if at least one of the variables is one.
2:15
If both variables are zero, the result is zero.
2:18
This is the OR operator.
2:19
Believe it or not, you don’t need anything else to build actual computers.
2:23
Obviously engineering a computer is still a very complex task,
2:27
but with just these three operators, we can build systems that perform
2:31
arithmetic on binary data and are able to store the results in memory.
2:36
Boole’s system was later
2:37
discovered by Claude Shannon, who applied it to electrical switches.
2:41
He turned a mathematical concept into a machine language,
2:45
and that has led us through the digital revolution.
Aristotle’s Law of the Excluded Middle
2:47
But it also cemented a worldview that truth comes in only two forms.
2:52
Computers work with zeros and ones, and in a sense, this reaffirms
2:56
the ancient philosophical principle that every proposition must be true or false.
3:02
This idea,
3:03
known as the law of the excluded middle, can be traced back to Aristotle.
3:07
Aristotle stated, for any proposition p,
3:10
either p is true or its negation negated p is true.
3:15
There is no middle ground.
3:16
At first sight,
3:17
this law seems intuitively obvious and in many cases it works perfectly well.
3:22
Either the coin shows heads or it doesn’t.
3:25
Either you are taller than your friend or you aren’t.
3:28
But on closer inspection, the cracks in this logic become obvious.
3:32
Statements about the future, for example, puzzled Aristotle himself.
3:36
Consider this there will be a sea battle tomorrow.
3:40
At the moment you say it is, it’s true or is it false?
3:43
The outcome hasn’t happened yet, so assigning a true value seems forced.
3:48
These are what Aristotle called future contingent propositions.
3:52
They expose limitations in the law that otherwise feels incontestable.
Łukasiewicz and Three Valued Logic
3:56
It took Yanukovich to formally address this challenge in the 20th century,
4:02
which was a Polish mathematician whose work focused on philosophical logic,
4:06
mathematical logic, and the history of logic.
4:09
He frequently collaborated with Alfred Tarski, another brilliant
4:13
Polish mathematician whom you might know from the Banach Tarski paradox.
4:17
the one Vsauce made a really popular video about.
4:20
In 1918, Łukasiewicz delivered a lecture at the University of Warsaw
4:25
in which he declared “a spiritual war upon
4:28
all coercion that restricts men’s free creative activity”.
4:32
He rejected Aristotle’s Law of the Excluded Middle, which restricted
4:36
propositions to true or false, and instead proposed his own logic system.
4:40
In 1920 Łukasiewicz formally introduced three valued logic.
4:44
In his system, a proposition could be true, false, or possible.
4:48
This third value was a way of dealing with statements
4:50
about the future and other indeterminate cases.
4:53
In his logic, the Law of the Excluded Middle no longer held universally.
4:57
If a statement was possible but not yet resolved P or negated
5:01
P was not guaranteed to be true.
5:03
It could remain indeterminate.
5:04
In three valued logic.
5:06
truth values can be represented in numerous ways depending on the definition.
5:10
But to keep this simple, we’ll use abbreviations F,
5:13
U, and T for false, unknown and true.
5:16
These map nicely onto the balanced ternary notation, a base three number system
5:21
which uses the digits minus one, zero and plus one.
5:24
In this notation minus one maps to false, zero to unknown, and plus one to true.
5:29
You’ll see why this is useful in a moment.
5:32
Just like George Boole, Łukasiewicz defined three basic operators from which
5:36
all other functions can be derived: negation, disjunction and conjunction.
5:41
Negation is straightforward.
5:43
If x is true, negated x is false.
5:45
If x is false, negated x is true, and if x is unknown, negated x
5:50
is also unknown.
5:51
Conjunction, also known as the AND operator, is trickier.
5:55
It follows the truth table you can see here, but it makes more sense
5:59
if we use the balanced ternary
6:00
representation and think of AND as the minimum function.
6:05
In every case, the result of AND is equal to the operand with the smallest value.
6:09
+1 and -1 is -1, since minus
6:13
one is smaller, and so on.
6:15
Now that you see how truth values can be mapped to the balanced ternary notation,
6:19
understanding the disjunction, also known as the or operator should be really easy.
6:24
It follows the maximum function.
6:25
The greater number dominates, so minus one or plus
6:29
one equals plus one, since plus one is greater than minus one.
6:33
Using just these three operators,
6:35
we can define much more complex functions like XOR,
6:38
which can be realized with two negations, two conjunctions and a disjunction.
6:42
But about those complex functions.
6:45
In Boolean logic, given to operators, we have two to the power of four so
6:49
16 distinct binary operators like AND,
6:52
NAND, XOR, XNOR, and so on.
6:55
Ternary logic has three to the power of nine, so
6:59
19,683 distinct operators.
7:02
This makes it quite complex, but in reality, just like in binary logic,
7:07
only the subset of functionally complete operators are used in practice.
7:11
Functional completeness is a property that allows certain operators to build
7:15
all other operators.
7:17
In binary logic, both the NAND and the NOR operators have that property,
Sponsored Segment
7:21
If you’d like to learn more about logic and digital circuits,
7:24
you might want to check out Brilliant, the sponsor of today’s video.
7:27
Brilliant is a learning platform filled with hands on problem
7:30
solving courses crafted by a team of researchers, teachers
7:34
and professionals from Stanford, MIT, Google and more.
7:38
Brilliant helps build your critical thinking skills for problem solving,
7:42
not memorizing.
7:43
In their brand new interactive course on digital circuits,
7:46
you will learn everything you need to know
7:48
to understand how binary computers work on the hardware level.
7:51
You will go from learning about the basics of logic gates to designing
7:55
arithmetic circuits, the kind of stuff you learn in university.
7:59
Moreover, Brilliant’s growing collection of programing courses
8:02
is a great way to learn how to think like a programmer.
8:05
To learn for free on Brilliant, go to Brilliant.org/codeolences, scan
8:10
the QR code on screen or click on the link in the description.
8:13
Brilliant also offers you 20% off of an annual premium subscription,
8:17
which gives you unlimited daily access to everything on Brilliant.
8:20
Thanks to Brilliant for sponsoring this video.
Implementations of Three Valued Logic This video was sponsored by Brilliant.
8:24
Łukasiewicz created
8:24
a consistent logical system, which was later expanded by logician
8:28
Stephen Cole Kleene and contemporary philosopher Graham Priest.
8:32
Once operators are defined, they can be implemented as physical logic
8:36
gates and arithmetic circuits, which eventually means computers.
8:40
In fact, almost three decades after Łukasiewicz published his system,
8:45
Soviet engineers built the Setun computer, the world’s first ternary computer.
8:50
Setun used the balanced ternary digits minus one, zero
8:54
and plus one, and showed in practice the ternary architecture could work.
8:58
I’m currently working on an in-depth video about the Setun Project.
9:01
It’s going to be my biggest video yet, so make sure to subscribe to catch it
9:06
when it’s published.
9:07
This is the best way to support my channel,
9:09
since 99% of people watching my videos are still not subscribed.
9:13
But back to the topic of this video.
9:15
The motivation for implementing ternary
9:17
logic might sound abstract, but it turns out to be very practical.
9:21
If you’re a programmer working with data, you may have already used it.
9:24
In SQL when you query data and encounter nulls, you’re
9:28
using three valued logic whether you realize it or not.
9:31
If you ask whether a column equals some value but the column is null,
9:35
the result is not true or false, but unknown.
9:39
This unknown propagates through logical expressions.
9:42
If we run the following SQL code, we can see how the logic operators act
9:46
just as the previous ones we talked about.
9:49
The results show exactly what we’ve discussed.
9:51
AND follows the minimum function, OR follows the maximum function,
9:56
and the empty spots represent null — The third value
10:00
Łukasiewicz called it possible and Kleene, later formalized it
10:03
as “unknown” in his Strong Logic of Indeterminacy.
10:06
This choice makes sense.
10:08
If databases forced everything into true or false, missing information would be
10:13
arbitrarily treated as one or the other, leading to incorrect results.
10:17
Instead, by embracing a third value, queries can represent
10:21
the actual state of knowledge — that some data simply isn’t available,
10:25
and if you zoom out, it’s hard to deny how natural three valued logic feels.
10:30
Our everyday reality is full of indeterminate states.
10:33
Binary logic forces us into yes or no decisions, often prematurely.
10:37
Three valued logic gives us a better language to represent reality,
10:41
as it really is: sometimes true, sometimes false, and sometimes simply unknown.
10:46
Thank you so much for watching!
10:48
If you enjoyed this video,
10:49
you might also enjoy this next one that you see on the screen right now.

