The hatt package

[Tags: bsd3, library, program]

Hatt is a command-line program which prints truth tables for expressions in classical propositional logic, and a library allowing its parser, evaluator and truth table generator to be used in other programs.


[Skip to ReadMe]

Properties

Versions0.1, 0.2, 0.3, 1.0, 1.1, 1.1.1, 1.2.0, 1.2.1, 1.3.0, 1.3.1, 1.4.0, 1.4.0.1, 1.4.0.2, 1.5.0.0, 1.5.0.2, 1.5.0.3
Change logNone available
Dependenciesansi-wl-pprint (==0.6.*), base (==4.*), cmdargs (>=0.7), containers (>=0.3 && <0.5), haskeline (==0.6.*), parsec (==2.1.*) [details]
LicenseBSD3
Copyright(c) 2011 Benedict Eastaugh
AuthorBenedict Eastaugh
Maintainerbenedict@eastaugh.net
CategoryLogic
Home pagehttp://extralogical.net/projects/hatt
Source repositoryhead: git clone git://github.com/beastaugh/hatt.git
Executableshatt
UploadedMon Oct 31 21:49:55 UTC 2011 by BenedictEastaugh
DistributionsNixOS:1.5.0.3
Downloads2174 total (94 in last 30 days)
Votes
0 []
StatusDocs uploaded by user
Build status unknown [no reports yet]

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees

Readme for hatt-1.3.1

Hatt

Hatt is a command-line program which prints truth tables for expressions in classical propositional logic, and a library allowing its parser, evaluator and truth table generator to be used in other programs.

Installation

Hatt is available from Hackage. To install it with cabal-install, update your list of known packages and then install Hatt.

$ cabal update
$ cabal install hatt

To build it from source, cd into the directory containing the Hatt source files, including hatt.cabal, and run cabal install.

Valid Hatt expressions

The following are all valid expression forms which can be parsed by Hatt, where ϕ and ψ are metalinguistic variables standing in for any valid expression. The parser isn't as smart about parentheses as it could be, so you have to follow these rules quite literally. This shouldn't be a great hardship, but it does mean that, for example, while (A -> B) is a valid expression, A -> B isn't.

Using the hatt command-line program

The default mode is interactive: you start the program, enter expressions at the prompt, and their truth tables are printed. Here's an example session.

$ hatt
Entering interactive mode. Type `help` if you don't know what to do!
> (A | B)
A B | (A | B)
-------------
T T | T
T F | T
F T | T
F F | F
> (p -> (q & ~r))
p q r | (p -> (q & ~r))
-----------------------
T T T | F
T T F | T
T F T | F
T F F | F
F T T | T
F T F | T
F F T | T
F F F | T
> (e <-> f)
e f | (e <-> f)
---------------
T T | T
T F | F
F T | F
F F | T
> exit

The --evaluate flag lets you pass a single expression to be evaluated directly.

$ hatt --evaluate="(P -> (Q | ~R))"
P Q R | (P -> (Q | ~R))
-----------------------
T T T | F
T T F | F
T F T | F
T F F | F
F T T | F
F T F | F
F F T | T
F F F | F

By default, hatt will print ASCII representations of expressions. If you have a Unicode-capable terminal, try passing the --pretty option to pretty-print expressions using the the more common logical symbols.

$ hatt --evaluate="(P -> (Q | ~R))" --pretty
P Q R | (P → (Q ∨ ¬R))
----------------------
T T T | F
T T F | F
T F T | F
T F F | F
F T T | F
F T F | F
F F T | T
F F F | F

You can enable pretty-printing while in interactive mode by using the pretty command.

If you pass the --coloured flag, hatt will colour the truth values in the tables which it prints: green for true, red for false. You can enable colouring during interactive mode by using the colour command.

Using Hatt in other programs

Hatt exposes the Data.Logic.Propositional module, which provides a simple API for parsing, evaluating, and printing truth tables.