Skip to content

emacs-elsa/trinary-logic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MELPA MELPA Stable CI

trinary = Three-valued logic for Emacs

See Three-valued logic.

Motivation

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.

API

Constructors

  • trinary-true
  • trinary-maybe
  • trinary-false

Predicates

  • trinary-true-p = true
  • trinary-maybe-p = maybe
  • trinary-false-p = false
  • trinary-possible-p = true or maybe
  • trinary-necessary-p = true

Operators

See Kleene logic.

  • trinary-not
  • trinary-and
  • trinary-or
  • trinary-happened
  • trinary-add-maybe = X or maybe