2024-09-03 18:25:54 -07:00
|
|
|
|
# Truth Table
|
|
|
|
|
This is a simple truth table generator. For more information about truth tables,
|
|
|
|
|
please see the [relevant Wikipedia article][1].
|
|
|
|
|
|
|
|
|
|
[1]: https://en.wikipedia.org/wiki/Truth_table
|
|
|
|
|
|
2024-09-14 01:18:20 -07:00
|
|
|
|
There is an instance of the web version of this program hosted here: [tt.zander.im][2]
|
|
|
|
|
|
|
|
|
|
[2]: https://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.
|
|
|
|
|
|
|
|
|
|
To build the CLI version, just run `make`. You will need SBCL, ASDF, and
|
|
|
|
|
Quicklisp. Quicklisp is used to load `uiop` and `with-user-abort`.
|
|
|
|
|
|
|
|
|
|
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. The web
|
|
|
|
|
server supports `-h` and `--help`, you can use them to see all the options it
|
|
|
|
|
supports. 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.
|
2024-09-03 18:25:54 -07:00
|
|
|
|
|
|
|
|
|
The format of the input propositions is fairly free-form. The above Wikipedia
|
|
|
|
|
article has some information about their format, as well as possible symbols for
|
2024-09-14 01:18:20 -07:00
|
|
|
|
operators. You can also take a look at the table near the top of `parse.lisp`
|
|
|
|
|
for all the variations supported by this program.
|
2024-09-03 18:25:54 -07:00
|
|
|
|
|
2024-09-14 01:18:20 -07:00
|
|
|
|
### CLI Usage
|
|
|
|
|
Here is the help output from the CLI (not web) program:
|
2024-09-03 18:25:54 -07:00
|
|
|
|
```text
|
|
|
|
|
usage: truth-table [options] <propositions...>
|
|
|
|
|
|
|
|
|
|
-h, --help print this message, then exit
|
2024-09-14 01:18:20 -07:00
|
|
|
|
-f, --format=<arg> specify the output format (*unicode*, ascii, latex, or html)
|
2024-09-03 18:25:54 -07:00
|
|
|
|
-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
|
2024-09-14 01:18:20 -07:00
|
|
|
|
-p, --pretty pretty print latex, html, etc. output
|
|
|
|
|
-l, --latin use the Latin T and F characters for truth values
|
2024-09-03 18:25:54 -07:00
|
|
|
|
|
|
|
|
|
The choice surrounded by '*' is the default. Arguments to long
|
|
|
|
|
options are also required for their short variant.
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Here is an example truth table:
|
|
|
|
|
```text
|
|
|
|
|
$ truth-table '(a /\ b) -> ~b'
|
|
|
|
|
┌───┬───┬────────────┐
|
|
|
|
|
│ a │ b │ a ∧ b → ¬b │
|
|
|
|
|
├───┼───┼────────────┤
|
|
|
|
|
│ ⊤ │ ⊤ │ ⊥ │
|
|
|
|
|
│ ⊤ │ ⊥ │ ⊤ │
|
|
|
|
|
│ ⊥ │ ⊤ │ ⊤ │
|
|
|
|
|
│ ⊥ │ ⊥ │ ⊤ │
|
|
|
|
|
└───┴───┴────────────┘
|
|
|
|
|
```
|