WeberLogic: Logic interpreter

[ bsd3, library, math, program ] [ Propose Tags ]

Logic interpreter


[Skip to Readme]
Versions [RSS] [faq] 0.1.0.0, 0.1.1, 0.1.2
Dependencies base (==4.6.*), parsec (==3.1.*) [details]
License BSD-3-Clause
Author Cameron Brandon White
Maintainer cameronbwhite90@gmail.com
Category Math
Home page https://github.com/cameronbwhite/WeberLogic
Uploaded by cameronbwhite at 2014-03-16T18:57:58Z
Distributions NixOS:0.1.2
Executables WeberLogic
Downloads 2480 total (4 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs uploaded by user [build log]
All reported builds failed as of 2015-12-08 [all 2 reports]

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Candidates


Readme for WeberLogic-0.1.0.0

[back to package description]

HsSymMath

Interactive mathematical languages written in haskell

Logic.hs

Formal logic parser

Command line

Currently the command line will take a logical expression as an argument and print out its corresponding truth table.

$ ./Logic
Enter Command
> TruthTable: a&b+c->~a&b
'a'   'b'   'c'   | (((a&b)+c)->(~a&b))
True  True  True  | False
True  True  False | False
True  False True  | False
True  False False | True 
False True  True  | True 
False True  False | True 
False False True  | False
False False False | True 

Enter Command
> ToNand: a&b->c 
(((((a|b)|(a|b))|((a|b)|(a|b)))|(((a|b)|(a|b))|((a|b)|(a|b))))|(c|c))

Enter Command
> ToNor: a&b->c
(((((a/a)/(b/b))/((a/a)/(b/b)))/c)/((((a/a)/(b/b))/((a/a)/(b/b)))/c))

Code

> And (Atom 'a') (Not (Atom 'b'))
(a&~b)

> truthTable $ And (Atom 'a') (Not (Atom 'b'))
'a'   'b'   | (a&~b)
True  True  | False
True  False | True 
False True  | False
False False | False

> toNand $ And (Atom 'a') (Not (Atom 'b'))
((a|(b|b))|(a|(b|b)))

> toNor $ And (Atom 'a') (Not (Atom 'b'))
((a/a)/((b/b)/(b/b)))

> let exp = And (Atom 'a') (Not (Atom 'b'))
> exp == toNand exp
True
> exp == toNor exp
True
> exp == toNor (toNand exp)
True