1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
──────────────────────────────────
Pinocchio — Truth Table Solver
──────────────────────────────────
NOTE: For interactive usage, consider running Pinocchio within an
instance of rlwrap[1].
Pinocchio is a simple truth-table solver supporting both ASCII/UTF-8 and
LaTeX output — perfect for repetitive university assignments.
When run without arguments, Pinocchio reads queries from the standard
input and prints truth tables to the standard output. If given
one-or-more non-option command-line arguments, the arguments are treated
as newline-separated lists of queries. The special filename ‘-’ may be
used to denote the standard input. The -s/--string option may also be
used to provide a query directly to Pinocchio as a command-line argument.
Here is a quick example of Pinocchio usage. Individual expressions to be
shown in the generated table are separated by a vertical-bar (‘|’).
$ pinocchio -s 'a ∧ b | a ∨ b'
a b │ a ∧ b │ a ∨ b
────┼───────┼──────
0 0 │ 0 │ 0
0 1 │ 0 │ 1
1 0 │ 0 │ 1
1 1 │ 1 │ 1
$ LC_ALL=C pinocchio -s 'a ∧ b | a ∨ b'
a b | a && b | a || b
----+--------+-------
0 0 | 0 | 0
0 1 | 0 | 1
1 0 | 0 | 1
1 1 | 1 | 1
$
Each vertical-bar-separated expression in the query may refer to
zero-or-more variables, where a variable is any lower- or uppercase ASCII
character (Unicode or multi-character variables are not supported).
Operators may also be written using either the corresponding Unicode
character or by using an ASCII alternative with C-like (but not
identical) syntax.
The list of operators are as follows:
Name │ Operator
─────────────┼─────────
Negation │ ¬, !
Conjunction │ ∧, &&
Disjunction │ ∨, ||
Exclusive Or │ ⊻, ⊕, ~
Implication │ ⇒, =>
Equivalence │ ⇔, <=>
Sometimes if your query is rather long, you may want to break it up
across multiple lines. To do this you can make use of line-continuation
by prefixing each continued line with a backslash. The following two
inputs are identical.
p ∧ ¬q | ¬p ∧ q | (¬p ∨ ¬q) ⇒ (p ∧ ¬q) ∨ (¬p ∧ q)
p ∧ ¬q
\ | ¬p ∧ q
\ | (¬p ∨ ¬q) ⇒
\ (p ∧ ¬q) ∨ (¬p ∧ q)
By default generated tables express boolean values as the binary digits 0
and 1, and are drawn using ASCII characters or Unicode characters if the
user is in a UTF-8 locale. This can all be customized with use of the
-t/--table-style and -b/--bool-style flags.
The -t/--table-style flag accepts one of the following styles as a
parameter:
Name │ Description
──────┼──────────────────────────────────────────────────────────────
ascii │ Draw the table using ASCII characters and C-like ASCII
│ operators.
│
utf8 │ Draw the table using Unicode box-drawing characters and
│ Unicode mathematical operators.
│
latex │ Output LaTeX markup suitable for embedding within a document.
│ Note that you may need to include the \usepackage{amsmath}
│ directive for certain symbols to render.
The -b/--bool-style flag accepts one of the following styles as a
parameter:
Name │ Symbols
────────┼─────────
alpha │ T, F
binary │ 0, 1
symbols │ ⊤, ⊥
[1]: https://github.com/hanslub42/rlwrap
|