See Three-valued logic.
Some problems are very awkwardly expressed in two-valued logic, mostly when we are dealing with uncertainty.
A typical example is flow analysis. Consider this piece of elisp code:
(let (a)
(if x
(setq a "a was set")
(message "we do nothing"))
a) ;; what is a?If we now ask a question "is a a string?" the answer is not
"definitely yes" nor "definitely no" but "maybe" because without
knowing what x is we can't tell.
This and many more use-cases can be found in Elsa, the Emacs Lisp Static Analyzer.
trinary-truetrinary-maybetrinary-false
trinary-true-p= truetrinary-maybe-p= maybetrinary-false-p= falsetrinary-possible-p= true or maybetrinary-necessary-p= true
See Kleene logic.
trinary-nottrinary-andtrinary-ortrinary-happenedtrinary-add-maybe= X or maybe