Propositional Logic
Propositional logic is the grammar of precise yes-or-no statements. A proposition is not a vague claim, a command, or an expression with an unassigned variable; it is a declarative sentence with a definite truth value. Once propositions are named by variables such as , , and , larger statements can be built with logical connectives. This lets mathematical arguments be checked by form rather than by the accidental wording of English.
This topic sits at the entrance to proof, set theory, circuit design, program specification, and Boolean search. Its power is that complicated statements can be reduced to small truth tables and algebraic laws. Its limitation is also important: propositional logic treats each simple sentence as atomic, so it cannot express "for every integer" or "there exists a vertex" until predicates and quantifiers are introduced.
Definitions
A proposition is a declarative sentence that is either true or false, but not both. "Seven is prime" is a proposition. "Close the door" is not, because it is a command. "" is not a proposition until has a value or the statement is quantified.
Compound propositions are built from simpler propositions using connectives.
| Connective | Symbol | Read as | True exactly when |
|---|---|---|---|
| Negation | not | is false | |
| Conjunction | and | both and are true | |
| Inclusive disjunction | or | at least one of is true | |
| Exclusive or | xor | exactly one of is true | |
| Conditional | if , then | not the case that is true and is false | |
| Biconditional | iff | and have the same truth value |
The conditional is often the first conceptual hurdle. In mathematics, does not assert that causes . It asserts that the failure pattern true and false never occurs. This is why a conditional with a false hypothesis is true: it has not been contradicted.
A compound proposition is a tautology if it is true for every assignment of truth values, a contradiction if it is false for every assignment, and a contingency otherwise. Two propositions and are logically equivalent, written , when is a tautology. An argument form is valid if the conclusion is true in every row in which all premises are true.
Key results
The most useful equivalences are the ones that remove conditionals, move negations inward, or rewrite a statement into a form that is easier to test.
The first two are De Morgan's laws. They are the propositional version of the set identities for complements of unions and intersections. The equivalence is the standard way to analyze implications by truth table or by Boolean algebra.
Here is a proof of the negated implication law using only equivalences:
This matters because it gives the exact shape of a counterexample. To disprove "if , then ," do not try to make both statements false. Make the hypothesis true and the conclusion false.
Rules of inference preserve truth. Modus ponens has the form , , therefore . Modus tollens has the form , , therefore . Hypothetical syllogism chains implications: from and , infer . Disjunctive syllogism says that from and , infer .
Visual
| T | T | T | F | F |
| T | F | F | T | T |
| F | T | T | F | F |
| F | F | T | F | F |
The last two columns match, so the table confirms .
Worked example 1: Translate and negate an access rule
Problem. Translate "A user can log in only if the password is correct and the account is active." Then negate the statement in plain English. Let mean "the user can log in," mean "the password is correct," and mean "the account is active."
Method.
- The phrase "only if" introduces a necessary condition. If the user can log in, then the necessary condition must hold.
- "The password is correct and the account is active" is .
- The whole statement is therefore
- Negate it algebraically:
Checked answer. The negation is: "The user can log in, and either the password is not correct or the account is not active." This is the only kind of observation that would refute the original rule. Merely finding an inactive account that cannot log in would not refute it, because the original statement only constrains users who can log in.
Worked example 2: Test an argument form
Problem. Determine whether this argument is valid:
- If the build passes, then the tests ran.
- If the tests ran, then the deployment is allowed.
- The deployment is not allowed.
- Therefore, the build did not pass.
Let mean "the build passes," mean "the tests ran," and mean "the deployment is allowed."
Method.
- The premises are , , and .
- From and , hypothetical syllogism gives
- From and , modus tollens gives
- This is exactly the proposed conclusion.
Checked answer. The argument is valid. A truth-table check reaches the same result: every row satisfying all three premises has . For example, if were true, then would be true by the first premise, would be true by the second premise, contradicting .
Code
from itertools import product
def implies(p, q):
return (not p) or q
def equivalent(expr1, expr2, variables):
for values in product([False, True], repeat=len(variables)):
env = dict(zip(variables, values))
if expr1(env) != expr2(env):
return False, env
return True, None
ok, counterexample = equivalent(
lambda e: not implies(e["p"], e["q"] and e["r"]),
lambda e: e["p"] and ((not e["q"]) or (not e["r"])),
["p", "q", "r"],
)
print(ok)
print(counterexample)
The program exhausts all truth assignments. It prints True and no counterexample, confirming the equivalence used in the first worked example.
Common pitfalls
- Reading as causation. In logic, it only rules out the row .
- Reversing "if" and "only if." " if " is ; " only if " is .
- Negating an implication as . The correct negation is .
- Treating inclusive "or" as exclusive "or." In mathematics, allows both to be true unless the problem explicitly says "but not both."
- Using a true conclusion to claim an argument is valid. Validity depends on form: every premise-true row must force the conclusion.
Truth tables scale exponentially: propositional variables require rows. For two or three variables, truth tables are usually the clearest method. For many variables, equivalence laws, normal forms, or satisfiability methods become more practical. This is one reason symbolic manipulation matters; it avoids rebuilding a huge table for every argument.
When translating requirements, mark each English connective. "Unless" often translates as an inclusive or or as a conditional after careful rewriting. "Necessary" and "sufficient" point in opposite directions: is sufficient for means , while is necessary for means . Writing a quick failure case helps verify the direction.
Validity and satisfiability answer different questions. An argument is valid when there is no truth assignment making all premises true and the conclusion false. A formula is satisfiable when at least one assignment makes it true. A set of specifications is consistent when their conjunction is satisfiable. Mixing these notions can make a correct truth table support the wrong claim.
Connections
- Predicates and quantifiers extends propositions with variables and domains.
- Proof techniques uses implication, contraposition, contradiction, and counterexamples.
- Sets and set operations mirrors De Morgan's laws with complements of unions and intersections.
- Boolean algebra and logic circuits implements propositions using gates.