Discrete Mathematics YMT211 · Fall 2026 Assoc. Prof. Ferhat Uçar
02 Propositional Logic Monday, September 28, 2026

Propositional Logic: Propositions, Connectives, Truth Tables

What counts as a proposition, the five connectives, truth tables, and the most misunderstood operator in computer science: the conditional.

Learning objectives

By the end of this week you can:

  • 1 Decide whether a sentence is a proposition, and explain why questions, commands and opinions are not.
  • 2 Use the connectives ¬, ∧, ∨, ⊕, →, ↔ and write their truth tables from memory.
  • 3 Build the truth table of any compound proposition and know that n variables give 2ⁿ rows.
  • 4 Explain why p → q is true when p is false, and translate “if”, “only if”, “unless”, “necessary” and “sufficient”.
  • 5 Form the converse, inverse and contrapositive, and know which one is equivalent to the original.
  • 6 Implement all of the above in Python (Lab 1).

★ the wow moment

A truth table for 300 variables has more rows than there are atoms in the universe.

n variables give 2ⁿ rows, and 2³⁰⁰ is about 10⁹⁰, while the observable universe has roughly 10⁸⁰ atoms. Yet industrial SAT solvers decide formulas with millions of variables every day, to verify chips and schedule airlines. Today you learn the truth table; by week 3 you will see why clever search beats brute force.

Propositions

Two conditions: it must state something (declarative), and it must have a definite truth value, true (T, 1) or false (F, 0). We name propositions with lowercase letters p,q,r,s,…p, q, r, s, \dots

Answers
  1. Proposition, and it is false (the capital is Ankara). False propositions are still propositions.
  2. Proposition, true.
  3. Not a proposition. It is an opinion; it has no definite truth value.
  4. Not a proposition. A question states nothing.
  5. Not a proposition. A command.
  6. Not a proposition. A number on its own asserts nothing. “2375 is odd” would be a proposition (a true one).
  7. Proposition, true.
  8. Not a proposition until we know xx. It is a propositional function P(x)P(x); P(4)P(4) is true, P(0)P(0) is false. Predicates are the topic of week 4.

Negation

p¬p
10
01

Negate the whole statement, not a word in it. The negation of “the queue is empty” is “the queue is not empty”, and the negation of 3>53 > 5 is 3≤53 \le 5 (not 3<53 < 5).

Connectives

Connectives build compound propositions from simpler ones. Here are all of them in one table: memorize it, you will use it every week.

pqp ∧ qp ∨ qp ⊕ qp → qp ↔ q
1111011
1001100
0101110
0000011
SymbolNameRead asTrue whenPython
p∧qp \land qconjunctionpp and qqboth are truep and q
p∨qp \lor qdisjunctionpp or qqat least one is true (inclusive)p or q
p⊕qp \oplus qexclusive orpp xor qqexactly one is truep != q
p→qp \to qconditionalif pp then qqnot (pp true and qq false)(not p) or q
p↔qp \leftrightarrow qbiconditionalpp if and only if qqboth have the same valuep == q

Truth tables

A truth table lists every combination of truth values of the variables and the resulting value of the formula. With nn variables there are 2n2^n rows, because each variable doubles the number of cases.

Build it column by column, from the inside out. For (p∨¬q)→(p∧q)(p \lor \neg q) \to (p \land q):

pq¬qp ∨ ¬qp ∧ q(p ∨ ¬q) → (p ∧ q)
110111
101100
010001
001100

Now let the computer do it. Type any formula, including the one above as (p | ~q) -> (p & q):

logic playground · truth_table.py

~ not · & and · | or · ^ xor · -> implies · <-> iff · variables p q r s …

python › 

The conditional, carefully

p→qp \to q is the connective students get wrong most often, and it is the one programmers rely on most. pp is the hypothesis (antecedent), qq the conclusion (consequent).

Think of it as a promise. “If you enter valid credentials, then you will be logged in.”

CredentialsResultPromise
validlogged inkept
validnot logged inbroken
invalidlogged innot broken: no promise was made about invalid credentials
invalidnot logged innot broken

The promise only says something when the hypothesis holds. When pp is false, p→qp \to q is vacuously true. That is why p→qp \to q has the same truth table as ¬p∨q\neg p \lor q, and why Python code often writes implications as not p or q.

Many ways to say p→qp \to q

EnglishLogic
if pp, then qq · qq if pp · qq whenever ppp→qp \to q
pp only if qqp→qp \to q
pp is sufficient for qqp→qp \to q
qq is necessary for ppp→qp \to q
qq unless ¬p\neg pp→qp \to q

Converse, inverse, contrapositive

From p→qp \to q we can build three related conditionals:

NameFormEquivalent to p→qp \to q?
converseq→pq \to pno
inverse¬p→¬q\neg p \to \neg qno
contrapositive¬q→¬p\neg q \to \neg pyes

“If today is Saturday, then tomorrow is Sunday.” Converse: “If tomorrow is Sunday, today is Saturday”, which happens to be true here, but only because of how the calendar works, not because of logic. Inverse: “If today is not Saturday, tomorrow is not Sunday.” Contrapositive: “If tomorrow is not Sunday, today is not Saturday”, which is always as true as the original. Check all of them in the playground: type (p -> q) <-> (~q -> ~p) and then (p -> q) <-> (q -> p).

The biconditional

p↔qp \leftrightarrow q (“pp if and only if qq”, often written “iff”) is true when pp and qq have the same truth value. It means (p→q)∧(q→p)(p \to q) \land (q \to p): pp is both necessary and sufficient for qq. Notice that p↔qp \leftrightarrow q is exactly ¬(p⊕q)\neg(p \oplus q). In code, it is p == q on booleans. We will go deeper next week.

Translating English into logic

  1. Find the atomic propositions and name them.
  2. Find the connectives, paying special attention to “only if”, “unless”, “but” (which means ∧\land) and “neither … nor” (¬p∧¬q\neg p \land \neg q).
  3. Add parentheses to match the intended meaning.
Answers
  1. r→(p∧¬q)r \to (p \land \neg q)
  2. “qq unless pp” means “if not pp then qq”: ¬p→q\neg p \to q (equivalently p∨qp \lor q).
  3. ¬p∧¬r\neg p \land \neg r

Logic on bits

Computers store truth values as bits, 1 and 0, and apply connectives to whole bit strings position by position. Python does this with integers:

a = 0b0110_1100
b = 0b1010_1010
print(f"{a & b:08b}")   # AND  → 00101000
print(f"{a | b:08b}")   # OR   → 11101110
print(f"{a ^ b:08b}")   # XOR  → 11000110

This is how file permissions (chmod 755), network masks and feature flags work. You will use it in the lab.

Summary

  • A proposition is a declarative sentence with exactly one truth value.
  • Six operators: ¬,∧,∨,⊕,→,↔\neg, \land, \lor, \oplus, \to, \leftrightarrow. Know their tables cold.
  • nn variables → 2n2^n rows.
  • p→qp \to q is false only when pp is true and qq is false; it equals ¬p∨q\neg p \lor q.
  • p→q≡¬q→¬pp \to q \equiv \neg q \to \neg p (contrapositive). The converse is not equivalent.
  • “pp only if qq” is p→qp \to q; necessary conditions are conclusions, sufficient conditions are hypotheses.

In industry

  • Every if-statement

    Conditions in code are compound propositions. A wrong negation (“not (a and b)” vs “not a and not b”) is one of the most common bugs in code review.

  • Access control

    Rules like “admin, or owner and not suspended” are propositions evaluated on every request of a web app.

  • Hardware

    AND, OR, NOT and XOR are physical gates. Your CPU is billions of tiny truth tables.

  • Requirements

    “The alarm sounds only if the door is open” and “if the door is open the alarm sounds” are different requirements. Engineers must tell them apart.

Lab 1: Truth-Table Engine

Write the connectives in Python, generate every row of a truth table, and build a tool that decides tautologies, contradictions and equivalences.

due Fri, Oct 2 · 23:59 · 10 points · open now

Go deeper

Tags:propositiontruth tablenegationconjunctiondisjunctionXORimplicationconditionalbiconditionalcontrapositiveconverse