Boolean logic: Turning decisions into code
How can a computer make a decision without understanding what it’s deciding?
In the first article, we explored how binary allows us to represent information with two values: 0 and 1.
But representing information is only the beginning. How do we use those values to evaluate conditions, make decisions and perform calculations?
The answer lies in a mathematical framework developed long before electronic computers existed.
When mathematics met logic
In 1854, George Boole published An Investigation of the Laws of Thought, exploring how logical reasoning could be expressed mathematically.
His work established the foundations of what we now call Boolean algebra.
Unlike conventional arithmetic, Boolean algebra operates on two logical values: true and false.
At the time, this was primarily a mathematical and philosophical concept.
Decades later, in 1937, Claude Shannon demonstrated in his master’s thesis how Boolean algebra could be applied to electrical switching circuits.
His research established a connection between abstract mathematical reasoning and physical electronic systems.
A logical expression could be implemented using electrical switches.
This connection became one of the foundations of digital computing.
The building blocks of logical decisions
Imagine checking into a hotel.
Before issuing a digital room key, the hotel’s system might need to verify two conditions:
- The room is ready.
- The guest’s identity has been verified.
Both conditions must be satisfied.
This is an example of an AND operation.
Boolean logic relies on several fundamental operations.
AND
The result is true only when both inputs are true.
Example: a room is ready AND the guest’s identity has been verified.
OR
The result is true when at least one input is true.
Example: an order qualifies for free delivery if its value exceeds a threshold OR the customer has a premium membership.
NOT
The result is the opposite of the input.
Example: a product can be displayed as available when it is NOT out of stock, assuming a simplified two-state inventory model.
XOR: exclusive OR
For two inputs, the result is true when exactly one input is true.
Example: a configuration requires selecting either standard delivery or express delivery, but not both.
Engineers draw these operations as logic gates. The shapes above follow the ANSI/IEEE standard, named after the American National Standards Institute, and they are the ones you’ll find in most textbooks.
These operations can be represented through a truth table.
| A | B | AND | OR | XOR | NAND | NOR |
|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 1 | 1 |
| 0 | 1 | 0 | 1 | 1 | 1 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 | 0 |
| 1 | 1 | 1 | 1 | 0 | 0 | 0 |
NOT is a unary operation: it takes one input and reverses its value.
NAND and NOR are the negated versions of AND and OR. Both are known as universal gates because any Boolean function can be implemented using only NAND gates or only NOR gates.
How logic becomes computation
Individual logic gates are relatively simple.
But combining them allows us to perform increasingly sophisticated operations.
Consider adding two binary digits.
Remember column addition at school: 7 + 5 = 12, so you write 2 and carry 1 to the next column. Binary works the same way, with only two digits. 1 + 1 = 10 in binary: write 0, carry 1. That carry is the digit passed to the next column.
| A | B | Sum | Carry |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 0 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
Notice that the sum column corresponds to XOR, while the carry column corresponds to AND.
By combining these two gates, we can construct a half-adder: a circuit capable of adding two binary digits.
A full-adder extends this capability by accepting a carry from a previous operation.
By combining multiple adders, computers can perform arithmetic on larger binary numbers.
This illustrates how complexity emerges from relatively simple building blocks.
Modern processors contain sophisticated arithmetic and logic circuits, built upon these same fundamental principles.
From technology to business value
At the software level, Boolean logic allows us to translate business policies into executable decisions.
Let’s return to our hotel check-in example.
A simplified rule could be expressed as:
canIssueKey = roomReady && identityVerified
The computer doesn’t understand hospitality.
It evaluates conditions defined by the application.
The same principle applies across industries.
In retail, a promotion might be available only when a customer is eligible AND the promotional period is active.
In telecommunications, a notification might be sent through an alternative channel when the preferred channel is unavailable.
In payments, a transaction might require additional verification when predefined risk conditions are met.
These rules enable businesses to automate processes, apply policies consistently and reduce repetitive manual decisions.
For customers, the benefit isn’t the underlying logical expression.
It’s the ability to check into a hotel, complete a purchase or receive an important notification without unnecessary friction.
However, real business processes are rarely as simple as a single Boolean expression.
They also involve changing states, incomplete information, exceptions, external dependencies and regulatory requirements.
Boolean logic provides a foundation, not a complete business process architecture.
When predefined rules reach their limits
Consider fraud detection.
A rule-based system can evaluate known indicators and trigger predefined actions.
But fraud patterns evolve. Interactions between signals can become too complex to capture through manually defined conditions alone.
Machine learning offers a complementary approach.
Instead of explicitly programming every possible condition, we train a model to identify patterns and estimate outcomes from data.
A fraud detection model might produce a risk score based on multiple transaction characteristics.
A separate policy layer can then determine which actions are permitted.
For example, an illustrative system could combine:
- A machine learning model estimating transaction risk.
- Business rules determining when additional verification is required.
- Regulatory controls enforcing mandatory requirements.
- Human review for exceptional situations.
The model contributes an estimate. The surrounding system determines how that estimate can be used.
Machine learning doesn’t make deterministic logic obsolete.
It changes where and how we apply it.
The architectural perspective
I believe this distinction will become increasingly important as we build agentic systems.
An AI agent may interpret a customer’s request, identify relevant information, select a tool and propose an action.
But should it be allowed to execute that action?
Imagine an AI assistant helping a customer manage a hotel reservation.
The agent might understand that the customer wants to change their booking.
It could identify alternative rooms, compare prices and propose a new reservation.
However, the system still needs to verify whether the agent is authorized to modify the booking, whether the proposed price is acceptable and whether additional customer approval is required.
Authorization, spending limits, regulatory requirements and business policies should not depend solely on an agent’s interpretation.
They should be enforced by independently implemented and tested controls.
Of course, deterministic rules are not automatically correct or secure. Their effectiveness depends on how accurately policies are defined, implemented and maintained.
The challenge is therefore not simply choosing between rules and AI.
It’s designing an architecture in which both contribute their respective strengths.
Intelligence to navigate complexity. Logic to enforce boundaries.
Sometimes, innovation isn’t about replacing an existing technology. It’s about combining it with a new one.
The next layer of abstraction
We now understand how information can be represented and used to evaluate logical conditions.
We’ve also seen how combinations of logic gates can perform arithmetic.
But what physically performs AND, OR and NOT? Shannon showed that electrical switches could. The question is which switch can do it billions of times per second, in something that fits in your pocket.
That brings us to one of the most important inventions of the twentieth century: the transistor.
Transistors: From one to billions
References and further reading
- George Boole, An Investigation of the Laws of Thought, 1854: gutenberg.org/ebooks/15114
- Claude E. Shannon, “A Symbolic Analysis of Relay and Switching Circuits”, master’s thesis, MIT, 1937; published in Transactions of the AIEE, 1938.
- Nand2Tetris, Boolean Logic and Boolean Arithmetic: nand2tetris.org
- MIT OpenCourseWare, Computation Structures: ocw.mit.edu
- NIST, AI Risk Management Framework: nist.gov/itl/ai-risk-management-framework
- OWASP, Top 10 for Large Language Model Applications: genai.owasp.org
About the author. I’m a Solution Architect with a background in Software Engineering, Product Management and Data Science & AI. My experience spans hospitality, retail, telecommunications and payments. I’m passionate about demystifying technology, connecting technical capabilities with business outcomes, and designing solutions that create meaningful human experiences.