Boolean functions and their construction
Boolean functions perform logical operations on truth values—true and false. This branch of mathematics helps programmers describe the logic of algorithms.
The concept of a Boolean function
Boolean functions are a mathematical way of describing logical operations. They are named after the British mathematician George Boole, who in the mid-19th century founded the field of mathematical logic—Boolean algebra. While conventional mathematical operations are performed on real numbers, Boolean algebra works with truth values: true and false. In the binary number system used in programming, these are represented by the numbers 1 and 0.
A simple example of a Boolean function: imagine a smart home program that controls lighting. To understand the state of a switch, the program uses logical values. If the light is on, the switch’s state in the program will be 1, or true. If it’s off, it will be 0 or false. Receiving a true or false answer based on the condition “Is the light on?” is the simplest Boolean function.
Boolean functions have inputs—the operands—and an output—the result. For example, there are light switches in two rooms and a hallway. To turn off the light in the hallway when the lights in both rooms are off, the smart home program needs to use the Boolean AND function. This function takes the values from the room switches—the inputs: if both are off (false and false), the output will also be false, and then the light in the hallway will also turn off.
What Boolean functions are commonly used in programming:
● AND — conjunction. Returns true if both outputs are true.
● OR — disjunction. Returns true if at least one of the outputs is true.
● NOT — NOT, negation, inversion. Inverts the value of the input: if the input was true, returns false, and vice versa.
● ID — identity. Returns the input value unchanged. True remains true, and false remains false.
● XOR – exclusive OR. Returns true if only one of the outputs was true.
● IF, THEN — “if…, then…”, implication. Defines the relationship between the premise and the consequent. Returns the consequent true if the premise is true. If the premise is false, the consequent can be either false or true.
● NAND — NAND-NOT. Inverts the result of the AND function; that is, it returns false only if both inputs are true.
● NOR — OR-NOT. Inverts the result of the OR function; that is, it returns true only if both inputs are false.
● XNOR — exclusive OR-NOT. Returns true if both inputs are the same, that is, both are true, or both are false.
Truth tables of Boolean functions
The operation of Boolean functions is illustrated using truth tables. They help understand the output of a Boolean function for all possible inputs and ensure that the functions used lead to the correct results. Let’s look at the truth tables for the three main types of Boolean functions:
1. AND — conjunction. Returns true if both outputs are true. The rows of the table indicate all possible combinations of input values A and B. The third column indicates the result of these combinations with the Boolean AND function, also known as conjunction or logical multiplication. Logical multiplication of inputs A and B is denoted by the symbol ∧.
The truth table of the AND function shows that the output 1 (true) is only possible when both outputs are also 1 (true). If at least one input is 0 (false), the output will also be 0 (false).
2. OR — disjunction. Returns true if at least one of the outputs is true. The OR function in Boolean algebra is also called disjunction or logical addition. The logical addition of inputs A and B is denoted by the symbol ∨.
The output of the OR function is 1 if at least one of the inputs is 1. When the values of input A and input B are both 0, the result of the logical addition will also be 0.
3. NOT — negation, inversion. Inverts the value of the input: if the input was true, it returns false, and vice versa. The Boolean NOT function — also known as negation or inversion — has only one input; the function changes its value to the opposite.
Superposition of functions
Function superposition is the combination of several Boolean functions in complex logical operations. Superposition allows for the creation of complex algorithms that employ multiple conditions that change the values of the inputs. Essentially, superposition is the sequential application of different functions to the initial inputs.
Let’s say we’re given a Boolean function (A AND B) OR (C AND D). This operation has four inputs: A, B, C, and D. As in regular mathematics, we first perform the AND operations within the parentheses to obtain new outputs, and then OR them.
Truth table for the function (A AND B) OR (C AND D):

The result of superposition is the application of the OR function to the inputs resulting from the AND operations on the pairs of inputs A, B, and C, D.
Dual functions
In Boolean algebra, every Boolean function has its own dual function, which is obtained from the original by inverting or replacing OR with AND and vice versa. Examples of dual functions:
● OR — OR and AND — AND;
● XOR — exclusive OR and XNOR — exclusive NOR-NOT;
● NOT — NOT and ID — identity;
● NAND — NAND-NOT and NOR — NOR-NOT.
Dual functions in programming help optimize computations. For example, if an algorithm requires calculating a logical function, it is sometimes more efficient to calculate its dual, especially if it has a simpler form. This can lead to improved performance or a reduction in the number of operations.
Decomposition of a function into variables
Minimization, or decomposition of a function into variables, allows one to represent a complex Boolean function as a combination of simpler functions, each dependent on a single variable. There are several methods for decomposing functions into variables:
● Karnaugh map method. The approach is based on transforming the truth tables of Boolean functions. The table cells are divided into rectangles to combine adjacent ones. The values in the resulting rectangles are the variables of the simplified logical expression of the function.
● Shannon decomposition. The essence of the method is to divide the truth table into two parts: one should contain inputs for which the variable takes the value 1, the other – for which it takes the value 0. As a result, the Boolean function takes the form of the sum of two subfunctions.
● Quine’s method. It involves two stages: first, the function is reduced to a reduced form using the operations of gluing and absorption. Second, the reduced function is reduced to a minimum by removing variables that do not affect the result of the original function.
● Quine-McCluskey Method. This approach simplifies the standard Quine method. It involves fewer gluing operations by initially dividing the truth table into regions with an equal number of zeros or ones.
● Blake-Poretsky method. The method is based on the transformation of the truth table of a function into Gray matrices, which represent ternary vectors.
Explore More IT Terms
#
A
- A Guide to SQL Query Formatting
- A/B testing
- Agile
- Algorithm complexity in 5 minutes
- Algorithms and Data Structures in C#
- An overview of the C # programming language
- An overview of the Python programming language
- Anaconda Python
- Android
- Android App Bundle
- Android SDK
- Angular
- Ansible
- Apache
- Apache Airflow
- Apache Kafka
- Apache Tomcat
- App Store
- AppCode
- Applications of the derivative
- Array-based stack
- ArrayList
- ASCII
- ASP.NET
- Assembly Language Lessons
B
C
D
- Data Analytics: applications of data analysis in companies
- Data Engineer - Who is it, what does a data engineer do, and an overview of the profession
- Data modeling: what it is, types, and process steps.
- Data preprocessing: a complete guide for beginners and professionals.
- Data structure
- Data structures
- Defining Aliases
- Defining Arrays
- Deque
- Developing a Website from Scratch
- Differential Equations
- Differentiation of functions
- Digital data: understand the importance of this asset for businesses.
- Double integrals
- Doubly linked lists
E
F
H
- Handling errors and exceptions
- How to effectively organize your workflow
- How to Learn Java: Tips for Beginner Developers
- How to Learn PHP: A Beginner's Guide
- How to Use S3 Storage in Kubernetes with CSI
- HTML
- HTML and CSS: Definition, Application, and Operating Principles
- HTML and CSS. Layout from Scratch: What to Learn, Where to Learn, and How Long Will It Take?
- HTML Frame Structure
- HTML Link Formatting
I
- if..else construction
- Infinite sequences and series
- Inheritance in Java: A Complete Guide to Principles and Implementation
- Inserting an Image
- Integration of functions
- Interactive Python Tutorial – Learn Programming from Scratch
- Interview Problem: Finding a Deleted Element in O(N)
- Interview Scare: The FizzBuzz Challenge
- Introduction to C++
- Introduction to Machine Learning
- Introduction to programming languages
- IT Specialist Resume (CV)
J
K
M
O
P
- PHP lessons
- Private DNS server and its configuration
- Programmer's Dictionary
- Programming with pseudocode
- Python Code Formatting Guide: PEP8
- Python for data analysis: how to do it and main libraries
- Python Lessons
- Python Superstar: 5 Ways to Use the * Operator
- Python vs. Julia: Should You Replace Python with Julia?
S
- SFML Graphics Library Tutorials
- SQL commands: see what they are, what the main ones are + examples
- SQL Interview Questions and Tasks
- SQL Lessons
- SQL Stored Procedures
- SQL Syntactic Sugar: The COALESCE Function
- Stack
- Start in analytics: Python or R
- Statistical analysis: importance for decision making.
- String formatting in Python
- Swift Lessons
- switch/match construct
T
W
- What are databases, and why do they need DBMS and SQL?
- What do Linux distributions consist of?
- What is .NET and what is it used for?
- What is a GPU in a computer, in simple terms?
- What is Big Data? Introduction, Types, Characteristics, and Examples
- What is Golang and what is it used for?
- What is Haskell and what is it used for?
- What is Kotlin and what is it used for?
- What is Linux? The History of Linux
- What is machine learning, and how does it work?
- What is Power BI: everything about the data analytics software
- What is the C++ programming language?
- What is the OSI Model: A Complete Explanation of the Seven Layers and Their Role in Networking
- What's the difference between x86 and ARM processors?
- Where to start learning the C programming language?
- Which Linux distribution should you choose? A Linux distribution overview
