WeberLogic: Logic interpreter

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

Logic interpreter

[Skip to Readme]


Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Versions [RSS], 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
Category Math
Home page
Uploaded by cameronbwhite at 2014-03-17T03:20:43Z
Reverse Dependencies 1 direct, 0 indirect [details]
Executables WeberLogic
Downloads 2692 total (12 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Successful builds reported [all 2 reports]

Readme for WeberLogic-0.1.2

[back to package description]


Logic interpreter and parsing library


cabal update
cabal install WeberLogic


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

Enter Command
> toNor: a&b->c


The library contains two modules.

  1. WeberLogic.Parser
  2. WeberLogic.Actions


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.

  • Data Types

    • LogicExp - A recursively defined data type which implements as abstract syntax tree. It provides the following type constructors which function as nodes in the AST: Not, And, Or, Implies, Iff, Nand, and Nor. The Predicate type constructor functions as the AST leaves.
    > import WeberLogic.Parser
    > Predicate 'A' [(Variable 'x', Name 'a')]
    > Not (Predicate 'A' [(Variable 'x', Name 'a')])
    > And (Predicate 'A' [(Variable 'x', Name 'a')]) (Predicate 'B' [])
    • Letter - This Data Constructor provies two Type constructors Variable and Name. They are used in the construction of Predicate which requires a list of type Letter
    > import WeberLogic.Parser
    > Predicate 'A' [(Variable 'x', Name 'a')]
  • Functions

    • parseExp
    > import WeberLogic.Parser
    > a = parseExp "Axa"
    > b = parseExp "~Axa"
    > c = parseExp "Axa&B"
    • parseArg
    > import WeberLogic.Parser
    > a = parseExp "|- Axa"
    > b = parseExp "~Axa, B |- Cax"
    > c = parseExp "Axa&B, B, C |- Ax->By"


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" 

> toNor $ readExp "A&~B"