Read-only mirror of truth-table

Alexander Rosenberg 87b47f9c94 Fix website title 2 月之前
.gitignore d85f58adf2 Finish port to asdf and make webserer template files 2 月之前
LICENSE 24904e73b5 Refactor to use ASDF 2 月之前
Makefile c6cadc3123 Make web server 2 月之前
README.md a78e132b72 Add better documentation 2 月之前
arguments.lisp c86b38db09 Small error in arguments.lisp 2 月之前
base-packages.lisp 421eff906d Add operands to syntax help message 2 月之前
build.lisp c6cadc3123 Make web server 2 月之前
cli.lisp 421eff906d Add operands to syntax help message 2 月之前
eval.lisp 2bdf936160 Fix incorrect parenthesis 2 月之前
parse.lisp 421eff906d Add operands to syntax help message 2 月之前
table.lisp c6cadc3123 Make web server 2 月之前
truth-table-web-wrapper f9091ad7c1 Fix some bugs with the web server 2 月之前
truth-table.asd c6cadc3123 Make web server 2 月之前
typeset.lisp 7a21f853da Clean up something 2 月之前
web.lisp 87b47f9c94 Fix website title 2 月之前

README.md

Truth Table

This is a simple truth table generator. For more information about truth tables, please see the relevant Wikipedia article.

There is an instance of the web version of this program hosted here: tt.zander.im

This repository contains three things: a Common Lisp library to parse and manipulate propositional logic expressions, a command line truth table generator, and a web-based truth table generator.

Building the CLI executable requires SBCL. Both the CLI and web server need Quicklisp. If you have Quicklisp installed, it should just get the rest of the dependencies for you.

CLI

To build the CLI version, just run make.

Here is the help output from the CLI program:

usage: truth-table [options] <propositions...>

  -h, --help          print this message, then exit
  --syntax-help       print a syntax help message, then exit
  -f, --format=<arg>  specify the output format (*unicode*, ascii, latex, or html)
  -s, --subexps       include sub-expressions in the output table
  -n, --no-vars       do not include variables in the output table
  -m, --multi-char    allow multi-character variable names
  -i, --no-implicit   do not use implicit 'and' operations
  -p, --pretty        pretty print latex, html, etc. output
  -l, --latin         use the Latin T and F characters for truth values

The choice surrounded by '*' is the default. Arguments to long
options are also required for their short variant.

Here is an example truth table:

$ truth-table '(a /\ b) -> ~b'
┌───┬───┬────────────┐
│ a │ b │ a ∧ b → ¬b │
├───┼───┼────────────┤
│ ⊤ │ ⊤ │     ⊥      │
│ ⊤ │ ⊥ │     ⊤      │
│ ⊥ │ ⊤ │     ⊤      │
│ ⊥ │ ⊥ │     ⊤      │
└───┴───┴────────────┘

Web

To run the web server, execute ./truth-table-web-wrapper. If you want to run it in the background, I recommend using something like GNU Screen. It should be noted, however, that it does not support HTTPS. If you want to use HTTPS, run the web server behind something like Nginx or HAProxy.

Here is the help output for the web wrapper program:

usage: truth-table-web-wrapper [options]

  -h, --help           print this message, then exit
  -d, --debug          enable debug output
  -p, --port=<arg>     specify port to use (default: 8000)
  -a, --address=<arg>  specify address to bind to (default: 127.0.0.1)

Arguments to long options are also required for their short variant.

Syntax

Here is the syntax for propositions (this is the same for both the web server and the CLI):

$ truth-table --syntax-help
┌───────────────────┬────────────────────────────────────────────┐
│ Operator          │ Syntax                                     │
├───────────────────┼────────────────────────────────────────────┤
│ open parenthesis  │ (                                          │
│ close parenthesis │ )                                          │
│ and               │ &, &&, ., /\, and, ∧                       │
│ nand              │ !&, !&&, nand, ~&, ~&&, ↑, ⊼               │
│ or                │ +, \/, or, |, ||, ∥, ∨                     │
│ nor               │ !|, !||, nor, ~|, ~||, ↓, ⊽                │
│ exclusive or      │ !=, ^, xor, ↮, ≢, ⊕, ⊻                     │
│ not               │ !, not, ~, ¬                               │
│ implies           │ ->, =>, >, implies, →, ⇒, ⊃, ⟹             │
│ converse          │ <, <-, <=, converse, ←, ⇐, ⊂, ⟸            │
│ biconditional     │ <->, <=>, <>, =, ==, iff, xnor, ↔, ⇔, ≡, ⊙ │
└───────────────────┴────────────────────────────────────────────┘
┌─────────┬────────────────┐
│ Operand │ Syntax         │
├─────────┼────────────────┤
│ true    │ 1, t, true, ⊤  │
│ false   │ 0, f, false, ⊥ │
└─────────┴────────────────┘
Two operands next to each other is treated as an 'implicit and' (unless this
feature is disabled).
Example:
  abc|d = a ∧ b ∧ c ∨ d