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.2, 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-17T03:20:31Z

Modules

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for WeberLogic-0.1.2

[back to package description]

WeberLogic

Logic interpreter and parsing library

Install

cabal update
cabal install WeberLogic

Interpreter

$ ./WeberLogic
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))

Library

The library contains two modules.

  1. WeberLogic.Parser
  2. WeberLogic.Actions

WeberLogic.Parser

The WeberLogic.Parser provides functions which read stings and return an abstract syntax tree (AST). The AST in implement with a data type called LogicExp and Letter.

WeberLogic.Actions

The WeberLogic.Actions modules provides functions which manipulate the LogicExp AST.

> import WeberLogic.Parser
> import WeberLogic.Actions

> mapM_ putStrLn $ truthTableStr $ readExp "A&B"
'a'   'b'   | (a&~b)
True  True  | False
True  False | True 
False True  | False
False False | False

> toNand $ readExp "A&~B" 
((a|(b|b))|(a|(b|b)))

> toNor $ readExp "A&~B" 
((a/a)/((b/b)/(b/b)))