WeberLogic: Logic interpreter

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] [Publish]

Warnings:

Logic interpreter


[Skip to Readme]

Properties

Versions 0.1.0.0, 0.1.1, 0.1.1, 0.1.2
Change log None available
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-16T19:05:10Z

Modules

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for WeberLogic-0.1.1

[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