bool

Logical expression tester

For installation instructions, see the file INSTALL.

Manual

See https://strahinja.srht.site/man/bool/bool.1.html.

Description

The first version of this program I wrote in November 1999 as a freshman on my university, in C++. I recently rediscovered it, shaking digital dust off a batch of my old files. Unfortunately, the original source doesn't compile under modern C++ compilers, so I decided to rewrite it, this time in C, using yacc/flex.

Its main idea is to take a logical expression, consisting of variable names, parentheses and logical operators, and for each combination of values of different variables output the values of the variables and the evaluated value of the expression.

Examples

$ printf "~A1 | A2 & A3\n" | bool | tsvtable -n -saa
+------------------+------------------+------------------+------------------+
|A1                |A2                |A3                |Result            |
|F                 |F                 |F                 |T                 |
|F                 |F                 |T                 |T                 |
|F                 |T                 |F                 |T                 |
|F                 |T                 |T                 |T                 |
|T                 |F                 |F                 |F                 |
|T                 |F                 |T                 |F                 |
|T                 |T                 |F                 |F                 |
|T                 |T                 |T                 |T                 |
+------------------+------------------+------------------+------------------+
$ printf "~A1 | A2 & A3\n" | bool -t | dtree -sa
OR
+--NOT
|  `--[ID(0) = "A1"]
`--AND
   +--[ID(1) = "A2"]
   `--[ID(2) = "A3"]

Prerequisites

Install

$ git clone https://git.sr.ht/~strahinja/bool
$ cd bool
$ su
# make install

With got:

$ got clone https://git.sr.ht/~strahinja/bool
$ got checkout bool.git
$ cd bool
$ su
# make install

Persistent build configuration file

The file config.mk will be sourced when building targets which also accept configuration through environment variables. For example, CPPFLAGS and PREFIX are specified in config.mk.

OpenBSD

Before running make(1), comment the CPPFLAGS definition in config.mk above the line with the “OpenBSD” comment and uncomment the one below it:

#CPPFLAGS	= -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \
#		  -D_XOPEN_SOURCE=700
# OpenBSD
CPPFLAGS	= -D_DEFAULT_SOURCE -D_POSIX_C_SOURCE=200809L \
		  -D_XOPEN_SOURCE=700 -D_BSD_SOURCE

Also, do the same for MANPREFIX:

#MANPREFIX	= $(DESTDIR)$(PREFIX)/share/man
# OpenBSD
MANPREFIX	= $(DESTDIR)$(PREFIX)/man

License

bool - Logical expression tester
Copyright © 2026 Страхиња Радић

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

Generated by slweb © 2020-2024 Strahinya Radich.