WeberLogic: Logic interpreter

[ bsd3, library, math, program ] [ Propose Tags ] [ Report a vulnerability ]

Logic interpreter


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.1, 0.1.2
Dependencies base (>=4.6 && <4.7), parsec (>=3.1 && <3.2) [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
Reverse Dependencies 1 direct, 0 indirect [details]
Executables WeberLogic
Downloads 2743 total (0 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user [build log]
All reported builds failed as of 2015-12-08 [all 2 reports]

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