3 ms·
In one respect, boolean logic is popular because of bits. If we had ternary processors, ternary logic would be more popular. In another respect, boolean logic
by mcdonje 5mo ago
In one respect, boolean logic is popular because of bits. If we had ternary processors, ternary logic would be more popular.
In another respect, boolean logic is popular because it's easy to reason about. The truth tables are relatively small in size and quantity. Not the case with ternary.
Ternary is probably way better at modeling the real world, but the complexity could make code hard to understand. Maybe that can be solved.
That said, boolean logic is more expressive than I think the blog post gives it credit for because it's usually only a part of the code. Like, it gets used a lot in SQL, where you're reasoning about with several columns. So, yeah, it's binary thinking on each dimension, but there are N dimensions.
The alternative presented is intuitionist logic, which is practically what in the computing world? Where is it used? Or where could or should it be used? I guess it can be represented in lamba calculus...
- tgv 5mo ago> If we had ternary processors, ternary logic would be more popular. Why? Boolean logic is older than its namesake, George Boole (1815-1864). Syllogisms are ancient. And we've had ternary systems, as well as others. And what does the third value represent? True and false are pretty universal when it comes to predicates, but anything in between is rather subjective.
- mgeorge001 5mo agoAccording to one of my clients that I have doing database development over the last 15 years, that 3rd value would be 'maybe'. Frustrated me to no end during development in the early years.
- antipurist 5mo agoThe third value could map to "mu" [1], or "unask the question". [1] https://en.wikipedia.org/wiki/Mu_(negative) https://en.wikipedia.org/wiki/Mu_(negative)
- Avshalom 5mo agogenerally a sort of Unknown though it depends on the formulation. https://en.wikipedia.org/wiki/Three-valued_logic https://en.wikipedia.org/wiki/Three-valued_logic
- tgv 5mo agoIt can also map unto "maybe", which opens another can of worms. Not that there's anything wrong with having an extra value "unknown", but it doesn't fundamentally alter the logic. As unknown in most cases means "it will be true or false at some point", its usage in computing is that of a singleton (who needs a word with 64 potentially unknown bits?), so dealing with unknown values as an exception is easier than permeating hardware with it. Using ternary to represent unknown is just not efficient.
- mcdonje 5mo agoA bool can be represented by a single bit. A tern(?) takes 2 bits or 1 trit to represent. Alternatively, a bool takes a trit to represent. So, in terms of radix economy, ternary computing is the most efficient, but you're leaving information density unused if you use it for binary, and representing ternary with binary is inherently inefficient.
- hcs 5mo agoenum Bool { True, False, FileNotFound }; https://thedailywtf.com/articles/What_Is_Truth_0x3f_ https://thedailywtf.com/articles/What_Is_Truth_0x3f_
- Daub 5mo ago> Ternary is probably way better at modeling the real world, but the complexity could make code hard to understand. Maybe that can be solved. Is it not true that the brain process in ternary? From the point of view of perception, I believe that we process the world in terms of pairwise comparisons. For example, the atomic indivisible of visual processing is figure/ground separation.
- peterlada 5mo agoYes. In opposites and in lack of data (null). Ternary thus fits better. Back in ancient CS classes my prof said that was a Russian attempt of building ternary processors with +1, 0, -1 represented as voltages. Another strike in for-ternary column is that it's the most efficient in the number of digits for representing numbers. Pi is optimally efficient but non-integer bases would break anyone's brain, I think.
- sam_lowry_ 5mo agoHere's a link documenting a the creation of a DIY ternary computer https://hackaday.io/project/28579-homebrew-ternary-computer https://hackaday.io/project/28579-homebrew-ternary-computer The author also made a more approachable miniseries in Russian: https://habr.com/ru/articles/496366/ https://habr.com/ru/articles/496366/
- Affric 5mo agoI thought e was optimal
- burnished 5mo agoNo. Neurons are 'aggregate and fire', and they either fire or they do not.
- jfengel 5mo agoThe brain doesn't do any of that. The brain is neural goo. It can arduously crank through simple logic problems with its ludicrously tiny memory (around 8 bytes). Everything else is intuition and guesswork. You can try to model those heuristics with various logics. Some logics work better in certain situations. Classical first order logic is actually really bad at modeling brain work, but it's simple to automate, so we use it even where it's wildly inappropriate.
- JackFr 5mo ago> Like, it gets used a lot in SQL Except it explicitly is not strictly Boolean in SQL because of nulls. X = Y can take the value true, false or null if either or both X and Y are null.
- mcdonje 5mo agoI thought about mentioning nulls, but it's a complicated subject. Not all columns are nullable. Null handling rules differ. It's not always ISO/ANSI.
- raverbashing 5mo agoActually "fun fact" we use something "kinda like" boolean logic, but distinct of the original "Prototypical BL" https://en.wikipedia.org/wiki/Two-element_Boolean_algebra https://en.wikipedia.org/wiki/Two-element_Boolean_algebra It has 2 operators: + and x (or more commonly: dot (.) - but this is more confusing on HN) Also both + and x operations distribute, so A+(BxC) = (A+B)x(A+C)
- danbruc 5mo agoIn one respect, boolean logic is popular because of bits. If we had ternary processors, ternary logic would be more popular. Ternary truth values combines two dependent binary questions - do we know the truth value of X and what is the truth value of X. The second one is meaningless if the first one is false. You can merge the two binary values into one ternary unknown, true, and false but this does not really change much. Depending on the context one or the other might be easier to work with. Option types generalize this, there is always a binary choice between the value is known or unknown, and if it is known, then there will also be the actual value. A ternary logic value is just Maybe<Boolean>.
- kqp 5mo agoThe known/unknown question is not separate in the real world, computing avoids it by asking binary questions only when they’re answerable. Considered generally, though, if I ask a true/false question then read your answer from a single bit, it may be the case that there is no possible way for you to not lie to me.
- danbruc 5mo agoWhich is exactly what I wrote. [...] two dependent binary questions [...] The second one is meaningless if the first one is false. Considered generally, though, if I ask a true/false question then read your answer from a single bit, it may be the case that there is no possible way for you to not lie to me. Then you are not asking a binary question. If there is, for example, the possibility that I might not know the answer, then you are actually asking two dependent questions - do you know the answer and if so, what is the answer.
- dTal 5mo agoHave you stopped beating your wife?
- danbruc 5mo agoTwo question, have you ever beaten your wife, if so, did you stop? You can not stop something that never started. Alternatively, if you know from context that the wife has been beaten in the past, then yes or no are perfectly fine as the only options. That question is obviously made as a trap because you can defend both answers. Yes, I am not beating her and actually never have, focusing on the current state. No, I did not stop because I never started, focusing on the state change. And the other party can do the same. No, so you did not stop beating your wife, so you are beating her. Yes, so you stopped beating your wife, then must have beaten here in the past. The correct response is of course that the question is not applicable because it assumes a state - the wife has been beaten in the past - that does not match reality. And not applicable is not a third answer to the question, it is a statement about the question itself. So in contexts where non-applicable binary question might occur, you have to first determine whether the question is applicable before proceeding to answer the question.
- LargoLasskhyfv 5mo agoSome of us have (balanced) ternary processors. Not even emulated on FPGAs anymore, somewhat more coarse ASIC, without all the IO, just PCIe. They aren't publically available, though. OTOH there is stuff like this planned to launch, which may compensate that lack of commercial availability somewhat: https://news.ycombinator.com/item?id=48177736 https://news.ycombinator.com/item?id=48177736 Though it's not ternary per se, it could be seen as several steps further above that.
- Tangurena2 5mo agoFrom an information theory perspective, the most efficient base for computations would be e (2.718). And trinary is closer than binary.
- mcdonje 5mo agoTrue. Radix economy.
- NooneAtAll3 5mo agoI still don't get what is being optimized for to get e as the answer
- amavect 5mo agoOptimizing for "radix economy", an argument that attempts to balance the digit cost against the choice of base. When the cost per digit equals the base, e turns out optimal. But when the cost per digit equals the digit's information content (bit, trit, etc; 1 trit = log(3,2) bits), all bases turn out about equal. https://en.wikipedia.org/wiki/Optimal_radix_choice https://en.wikipedia.org/wiki/Optimal_radix_choice
- amavect 5mo agoI have an axe to grind. Radix economy makes a shallow argument when calculating the wrong per-digit information cost. I need some functions to show what I mean. Calculate logarithms, calculate the number of digits, and convert a base-n unit of information into base-2 units of information. Finally, calculate the information cost: the number of digits, times the information needed per digit. import ln, floor define log := (num,base) -> ln(num) / ln(base) define digits := (num,base) -> floor(log(num,base) + 1) define tobits := (base) -> log(base,2) define infocost := (num,base) -> digits(num,base) * tobits(base) define infocost_wikipedia := (num,base) -> digits(num,base) * base define infocost_tbwtc := (num, base) -> (digits(num,base) - 1) * tobits(base) + tobits(base- 1) https://www.desmos.com/calculator/1wfdtsuaav https://www.desmos.com/calculator/1wfdtsuaav I define a logarithmic per-digit information cost, following information theory. For example, 1 trit = log(3,2) bits. This results in no advantage for any base (in which case, choose base 2). Wikipedia uses a linear per-digit information cost equal to the base. This holds when communicating options takes linear time (Wikipedia's example of a phone menu). This results in advantage for base e (in which case, choose base 3). The video "The Best Way To Count" uses the logarithmic digit cost, and also notes that the leading digit carries less information (it excludes 0, like a IEEE floating point mantissa). This results in advantage for base 2. Therefore, know the context to apply the right cost analysis! https://en.wikipedia.org/wiki/Optimal_radix_choice https://en.wikipedia.org/wiki/Optimal_radix_choice https://en.wikipedia.org/wiki/Talk:Optimal_radix_choice#Why_assume_that_the_cost_of_each_digit_is_proportional_to_b https://en.wikipedia.org/wiki/Talk:Optimal_radix_choice#Why_...? https://en.wikipedia.org/wiki/Talk:Optimal_radix_choice#Binary_has_the_lowest_radix_economy_for_humans https://en.wikipedia.org/wiki/Talk:Optimal_radix_choice#Bina... https://youtu.be/rDDaEVcwIJM?t=701 https://youtu.be/rDDaEVcwIJM?t=701 timestamp 11:41
- matt_kantor 5mo ago> The alternative presented is intuitionist logic, which is practically what in the computing world? Where is it used? Or where could or should it be used? The Curry-Howard correspondence[1] tells us that every function is a proof (in the intuitionistic sense) of the proposition represented by its return type, given the axioms ("context" in the article) represented by its arguments. This fact is leveraged heavily by proof assistants (as mentioned in the article), but is generally useful in any statically-typed programming language. [1]: https://en.wikipedia.org/wiki/Curry%E2%80%93Howard_correspondence https://en.wikipedia.org/wiki/Curry%E2%80%93Howard_correspon...
- ufocia 5mo agoFuzzy logic may be one approximation. Analog processors may be another.
- matt_kantor 5mo agoDid you reply to the wrong comment? I don't see how this relates to what I wrote.
- nyrikki 5mo agoThe Curry-Howard correspondence formal relationship between intuitionistic logic and typed lambda calculus. Intuitionistic logic doesn’t hold PEM as a priori. Due to many issues like [0] you actually lose the univalent in HoTT. That is what allows you to say two programs are equivalent by behavior. No comment on the OP, but be careful as it is a rabbit hole. [0] https://ncatlab.org/nlab/show/Diaconescu-Goodman-Myhill+theorem https://ncatlab.org/nlab/show/Diaconescu-Goodman-Myhill+theo...