Glossary
Associative Law
A boolean property stating that the grouping of operands in a series of AND or OR operations does not affect the result.
Example:
When checking conditions for a quest, (hasKey && hasMap) && foundTreasure is the same as hasKey && (hasMap && foundTreasure) due to the Associative Law.
Boolean Expression Equivalence
The state where two boolean expressions produce the same output for all possible input combinations.
Example:
To prove that !(A && B) is equivalent to !A || !B, you would show they always yield the same result.
Commutative Law
A boolean property stating that the order of operands in an AND or OR operation does not affect the result.
Example:
Checking if isRaining && isCold or isCold && isRaining yields the same result for deciding to wear a jacket, illustrating the Commutative Law.
Consensus Theorems
A set of boolean theorems that help simplify expressions with specific patterns, often involving a variable, its negation, and another variable.
Example:
If a system checks (sensorA || (!sensorA && sensorB)), it can be simplified to just sensorA || sensorB using a Consensus Theorem.
DeMorgan's Theorems
A set of two crucial boolean theorems that describe how to negate complex expressions involving AND and OR operations.
Example:
To check if a user is not both an admin and active, you can use !(isAdmin && isActive), which by DeMorgan's Theorems is !isAdmin || !isActive.
Distributive Law
A boolean property that allows an AND operation to be distributed over an OR operation, or vice-versa, similar to multiplication over addition in algebra.
Example:
If a character needs to be (strong && agile) || (strong && intelligent), this can be simplified to strong && (agile || intelligent) using the Distributive Law.
Double Negation
A boolean property stating that negating a boolean variable twice returns the original variable.
Example:
If a door is !(!locked), it means the door is locked because of Double Negation.
Idempotent Law
A boolean property stating that applying an operation (AND or OR) to a variable with itself yields the variable itself.
Example:
If a game character has isFlying || isFlying, their state is simply isFlying due to the Idempotent Law.
Order of Operations (Boolean)
The established hierarchy for evaluating boolean expressions, where NOT (`!`) is evaluated first, followed by AND (`&&`), and then OR (`||`).
Example:
In !A && B || C, !A is evaluated first, then the result is ANDed with B, and finally that result is ORed with C, following the Order of Operations.
Proof by Simplification
A method to demonstrate boolean expression equivalence by transforming one expression into another using boolean properties and identities.
Example:
Simplifying A && (A || B) to just A is an example of Proof by Simplification using boolean algebra.
Proof by Testing All Cases
A method to demonstrate boolean expression equivalence by constructing a truth table and verifying that both expressions yield identical outputs for every possible input combination.
Example:
Using a truth table to confirm that A || !A always evaluates to true is an instance of Proof by Testing All Cases.
Truth Table
A tabular representation that lists all possible input combinations for a boolean expression and the corresponding output for each combination.
Example:
A Truth Table for A && B would show that the output is only true when both A and B are true.