Truth Tables for Program Decisions
A truth table assigns an expected outcome to each combination of independent Boolean inputs.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Model a small policy
A member can open a workshop if payment is current or a waiver exists, and the session is open. With three Boolean inputs there are eight combinations. The two reasons for admission can be represented as an inner disjunction. Operator precedence governs how an unparenthesized expression groups.
Find a revealing row
Test a closed session for a current member. A wrongly grouped expression may grant entry because it checks the session status only on the waiver side. Include both reasons as separate positive cases. See De Morgan's laws when writing the complementary denial predicate.[1][2]
Build one row for each combination
Suppose an edit requires an open review window and either ownership of a record or a delegated editor role. With three Boolean conditions there are eight combinations. Write each outcome under \(\text{open}\land(\text{owner}\lor\text{delegate})\). A closed window with an owner should still be rejected. An open window with only a delegated editor should be accepted. These two rows can distinguish common wrong groupings. Operator precedence explains how missing parentheses can change the expression.
Check the inputs and effects surrounding the Boolean result
Some facts can be guaranteed by earlier validation. For example, a malformed record might never enter the edit check. Mark such combinations separately so the truth table does not imply the program supports arbitrary inputs. A table of eight Boolean rows can verify the pure predicate, then a component integration test can observe that rejected and accepted actions change the correct records.
When adding a new criterion, first decide whether it can override the others or requires their agreement. Record the actual policy as expected outcomes before translating it to Boolean operators. This keeps the design review grounded in examples.