The WeberLogic package

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain]

Warnings:

Logic interpreter


[Skip to ReadMe]

Properties

Versions0.1.0.0, 0.1.1, 0.1.1, 0.1.2
Change logNone available
Dependenciesbase (==4.6.*), parsec (==3.1.*) [details]
LicenseBSD3
AuthorCameron Brandon White
Maintainercameronbwhite90@gmail.com
CategoryMath
Home pagehttps://github.com/cameronbwhite/WeberLogic
ExecutablesWeberLogic
UploadedSun Mar 16 19:05:10 UTC 2014 by cameronbwhite

Modules

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for WeberLogic-0.1.1

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