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

Versions 0.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
Dependencies base (==4.2.*), cmdargs (==0.6.*), containers (==0.3.*), parsec (==2.1.*) [details]
License BSD3
Copyright (c) 2011 Benedict Eastaugh
Author Benedict Eastaugh
Maintainer benedict@eastaugh.net
Stability experimental
Category Logic
Home page https://github.com/beastaugh/hatt
Source repository head: git clone git://github.com/beastaugh/hatt.git
Uploaded Sun Jan 30 18:13:46 UTC 2011 by BenedictEastaugh
Distributions NixOS:1.5.0.3
Downloads 3012 total (39 in the last 30 days)
Votes
0 []
Status Docs not available [build log]
All reported builds failed as of 2015-11-20 [all 4 reports]

Modules

  • Data
    • Logic
      • Data.Logic.Propositional
        • Data.Logic.Propositional.Core
        • Data.Logic.Propositional.Parser
        • Data.Logic.Propositional.Tables

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for hatt

Readme for hatt-0.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.

  • Variables: P, Q, R etc.---basically anything in the character class [A-Z]
  • Negation:
  • Conjunction: (ϕ & ψ)
  • Disjunction: (ϕ | ψ)
  • Conditional: (ϕ -> ψ)
  • Biconditional: (ϕ <-> ψ)

Using the hatt command-line program

The --evaluate flag lets you pass an expression to be evaluated directly. Here's an example session doing just that.

$ 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

Note that while you need to use ASCII symbols to interact with hatt, it pretty-prints expressions using the more common logical symbols. The Hatt library exposes the showAscii function which will print expressions in the format in which they're entered.

Using Hatt in other programs

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