Add better documentation
This commit is contained in:
parent
7a21f853da
commit
a78e132b72
71
README.md
71
README.md
@ -12,26 +12,20 @@ This repository contains three things: a Common Lisp library to parse and
|
|||||||
manipulate propositional logic expressions, a command line truth table
|
manipulate propositional logic expressions, a command line truth table
|
||||||
generator, and a web-based truth table generator.
|
generator, and a web-based truth table generator.
|
||||||
|
|
||||||
To build the CLI version, just run `make`. You will need SBCL, ASDF, and
|
Building the CLI executable requires SBCL. Both the CLI and web server need
|
||||||
Quicklisp. Quicklisp is used to load `uiop` and `with-user-abort`.
|
Quicklisp. If you have Quicklisp installed, it should just get the rest of the
|
||||||
|
dependencies for you.
|
||||||
|
|
||||||
To run the web server, execute `./truth-table-web-wrapper`. If you want to run
|
### CLI
|
||||||
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.
|
|
||||||
|
|
||||||
The format of the input propositions is fairly free-form. The above Wikipedia
|
To build the CLI version, just run `make`.
|
||||||
article has some information about their format, as well as possible symbols for
|
|
||||||
operators. You can also take a look at the table near the top of `parse.lisp`
|
|
||||||
for all the variations supported by this program.
|
|
||||||
|
|
||||||
### CLI Usage
|
Here is the help output from the CLI program:
|
||||||
Here is the help output from the CLI (not web) program:
|
|
||||||
```text
|
```text
|
||||||
usage: truth-table [options] <propositions...>
|
usage: truth-table [options] <propositions...>
|
||||||
|
|
||||||
-h, --help print this message, then exit
|
-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)
|
-f, --format=<arg> specify the output format (*unicode*, ascii, latex, or html)
|
||||||
-s, --subexps include sub-expressions in the output table
|
-s, --subexps include sub-expressions in the output table
|
||||||
-n, --no-vars do not include variables in the output table
|
-n, --no-vars do not include variables in the output table
|
||||||
@ -56,3 +50,54 @@ $ truth-table '(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:
|
||||||
|
```text
|
||||||
|
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):
|
||||||
|
```text
|
||||||
|
$ 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
|
||||||
|
```
|
||||||
|
2
web.lisp
2
web.lisp
@ -509,7 +509,7 @@ arguments."
|
|||||||
(cerror "Ignore the extra arguments." 'command-line-error
|
(cerror "Ignore the extra arguments." 'command-line-error
|
||||||
:message "extra non-option arguments"))
|
:message "extra non-option arguments"))
|
||||||
(when (option-value 'help opts)
|
(when (option-value 'help opts)
|
||||||
(print-usage t *command-line-spec* "truth-table-webserver"
|
(print-usage t *command-line-spec* "truth-table-web-wrapper"
|
||||||
:print-astrisk nil)
|
:print-astrisk nil)
|
||||||
(if cmdline-error
|
(if cmdline-error
|
||||||
(uiop:quit 1)
|
(uiop:quit 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user