Welcome to the World of Logic
Mathematical logic is the rigorous framework for understanding and formalizing reasoning. It's a cornerstone of both modern mathematics and computer science, providing the tools to build sound arguments, design complex computer systems, and even explore the limits of what can be proven.
This guide is designed to be an interactive journey. Instead of just reading, you'll get to engage with the core concepts directly. You'll build truth tables, visualize how quantifiers change a statement's meaning, and see how rules of inference allow us to derive new truths from existing knowledge. The goal is to move from abstract theory to tangible understanding.
Why is Logic So Important?
In mathematics, logic provides the foundation for proofs. In computer science, it's the bedrock of everything from chip design (logic gates) and programming languages (`if-then-else` statements) to artificial intelligence and database queries. A solid grasp of logic is essential for clear, structured, and effective problem-solving in any technical field.
Part 1: Propositional Logic
Propositional logic is the starting point. It deals with simple, declarative sentences called **propositions**, which can be either definitively True or False. We combine these simple propositions using logical connectives to form more complex statements. This section lets you explore these fundamental building blocks.
Connective Explorer
Click a connective to see its details.
Select a connective above to learn about it.
Truth Table Generator
Enter a formula using p, q, r and connectives: and, or, not, ->, <->. Use parentheses for grouping.
Propositional Equivalences
Just like in algebra, logical statements can be rewritten into different, yet equivalent, forms. These equivalences are the rules we use to simplify and manipulate logical expressions. Click each law to expand it.
De Morgan's Laws
¬(p ∧ q) ≡ ¬p ∨ ¬q
¬(p ∨ q) ≡ ¬p ∧ ¬q
"The negation of a conjunction is the disjunction of the negations."
Distributive Laws
p ∧ (q ∨ r) ≡ (p ∧ q) ∨ (p ∧ r)
p ∨ (q ∧ r) ≡ (p ∨ q) ∧ (p ∨ r)
Associative Laws
(p ∧ q) ∧ r ≡ p ∧ (q ∧ r)
(p ∨ q) ∨ r ≡ p ∨ (q ∨ r)
Commutative Laws
p ∧ q ≡ q ∧ p
p ∨ q ≡ q ∨ p
Double Negation
¬(¬p) ≡ p
Identity & Domination
p ∧ T ≡ p (Identity)
p ∨ F ≡ p (Identity)
p ∧ F ≡ F (Domination)
p ∨ T ≡ T (Domination)
Part 2: Predicate Logic
Propositional logic is powerful, but limited. It can't analyze the internal structure of a statement like "All humans are mortal." Predicate logic extends our language by introducing **predicates** (properties or relations), **variables** (representing objects), and **quantifiers** (which state the scope of a claim). This allows us to reason about objects and their properties in a much more granular and expressive way.
Quantifier Visualizer
One of the most critical concepts in predicate logic is that the **order of quantifiers matters**. Let's visualize this. Consider a 5x5 grid of cells and the predicate P(x,y) meaning "the cell at row x, column y is colored." See what happens when we try to satisfy two different statements.
Explanation
Part 3: Rules of Inference
How do we construct a valid argument? We use **rules of inference**—fundamental, valid argument forms that act as building blocks. These rules allow us to take a set of true premises and derive a new conclusion that is guaranteed to be true. They are the engine of logical deduction.
Propositional Inference Rules
These rules operate on propositions. Click to expand each rule.
Modus Ponens
Form: If p → q and p, then q.
If it rains, the ground is wet. It is raining. Therefore, the ground is wet.
Modus Tollens
Form: If p → q and ¬q, then ¬p.
If it rains, the ground is wet. The ground is not wet. Therefore, it is not raining.
Hypothetical Syllogism
Form: If p → q and q → r, then p → r.
If I study, I pass the exam. If I pass the exam, I am happy. Therefore, if I study, I am happy.
Disjunctive Syllogism
Form: If p ∨ q and ¬p, then q.
The key is in the box or the drawer. The key is not in the box. Therefore, it is in the drawer.
Addition & Simplification
Addition: If p, then p ∨ q.
Simplification: If p ∧ q, then p.
Quantifier Inference Rules
These rules allow us to introduce or eliminate quantifiers, bridging the gap between general statements and specific instances.
Universal Instantiation (UI)
Form: From ∀x P(x), infer P(c).
From "All humans are mortal," we can infer "Socrates is mortal."
Universal Generalization (UG)
Form: From P(c) for an arbitrary c, infer ∀x P(x).
If we can prove a property for a truly arbitrary number, we can say it holds for all numbers.
Existential Instantiation (EI)
Form: From ∃x P(x), infer P(c) for some new constant c.
From "Someone won the lottery," we can say "Let's call the winner 'c'" and reason about them.
Existential Generalization (EG)
Form: From P(c), infer ∃x P(x).
From "My dog Fido has fleas," we can infer "There exists a dog with fleas."