Skip to content

A small library to evaluate ternary logic expressions under various systems.

License

Notifications You must be signed in to change notification settings

jonathanmfung/SimpleTernaryLogic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

SimpleTernaryLogic (STL)

A small library to evaluate ternary logic expressions under various systems.

Common boolean logic is dictated by two values, True and False. Ternary logic allows for an intermediate value, usually I or U. Different systems designate this extra value to lean towards True or False, or be more neutral.

Installation

No specific GHC version required. Run the following to load the library.

ghci SimpleTernaryLogic.hs

Usage

The front-end syntax is similar to connectives in formal logic.

Logic SymbolSTL SyntaxMeaning
¬!Not
&And
Or
>>Material Implication
<->Biconditional Equivalence

Construct Operations (Ops) with lambdas. Ops take in two arbitrary Expressions and returns the specified composition:

type Op = Expression -> Expression -> Expression
myOp :: Op
myOp = (\e1 e2 -> ((e2 || e1) >> ((!) e2) <-> (e1 & e2)))

myOp T F
-- (((F ∨ T) → ¬F) ↔ (T ∧ F))

Remember that logic connectives are Ops themselves:

(&), (||), (>>), (<->) :: Op

Systems

Currently, there are three supported Systems:

data Syst
  = Kleene
  | Lukasiewicz
  | Bochvar

The main interface is through truthTable. This evaluates the truth table of the given Op under a specified System.

truthTable :: Syst -> Op -> Table Expression
truthTable Lukasiewicz myOp
--       F.	U.	T.
-- F:	F	F	T
-- U:	F	U	U
-- T:	F	T	F

Resources

About

A small library to evaluate ternary logic expressions under various systems.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published