Logic and Boolean Algebra
At the most granular level, computers and Machine Learning algorithms operate on Logic. Whether it's a Decision Tree splitting data based on a condition or a Neural Network using a step function, Propositional Logic and Boolean Algebra are the tools used to formalize these decisions.
1. Propositional Logic
A proposition is a declarative statement that is either True (T) or False (F). In ML, we often use propositions to evaluate features.
- Example Proposition (): "The house has more than 3 bedrooms."
- Example Proposition (): "The price is less than $500,000."
Logical Operators
We combine propositions using logical operators to create complex decision boundaries.
| Operator | Symbol | Meaning | ML Context |
|---|---|---|---|
| AND | Both must be true. | Feature A > 10 AND Feature B < 5. | |
| OR | At least one must be true. | If Category is "Dog" OR "Cat", then "Pet". | |
| NOT | Reverses the value. | If NOT (Missing Value). | |
| XOR | Exactly one is true. | Binary features that are mutually exclusive. |
2. Truth Tables
A truth table lists all possible combinations of inputs and the resulting output. This is the simplest way to visualize a discrete function.
Example: The AND () Operator
| T | T | T |
| T | F | F |
| F | T | F |
| F | F | F |
3. Boolean Algebra in Machine Learning
Boolean Algebra is the branch of mathematics that deals with variables that have two values: .
A. Binary Classification
In binary classification, our target variable is a Boolean. We use logic to determine the threshold: If , then True, else False.
B. Decision Trees
Decision Trees are essentially a nested series of logical "IF-THEN-ELSE" statements. Each node in the tree evaluates a logical proposition to route the data down the correct branch.
C. Logic Gates in Neural Networks
Early models of artificial neurons (the McCulloch-Pitts neuron) were designed to mimic logic gates. By adjusting weights and thresholds, a single neuron can be made to act as an AND gate or an OR gate.
4. Conditional and Bi-conditional Logic
- Implication (): "If , then ." This forms the basis of Rule-Based Systems and Expert Systems.
- Equivalence (): " if and only if ." This is used to define identical behaviors in different models.
In some forms of logic-based learning, we use Inductive Logic Programming (ILP) to learn formal rules from data, rather than just adjusting numerical weights.
5. Boolean Minimization
In large-scale systems, we use Boolean Algebra laws (like De Morgan's Laws) to simplify complex logical expressions. This is similar to how we optimize code or simplify mathematical models to make them more efficient.
- De Morgan's Law 1:
- De Morgan's Law 2:
Now that we understand sets and the logic to navigate them, we can explore Graph Theory, which is how we model complex relationships and networks.