Logic

AND, OR: Combining Propositions

Цели урока

  • Understand conjunction (AND) and when it is true
  • Master disjunction (OR) and its nuances
  • Distinguish inclusive from exclusive OR
  • Learn to build and read truth tables

"Discount for students OR pensioners" - what about a student who is also a pensioner? Logic and everyday language diverge more often than expected.

  • Filters in online stores: "red AND size M"
  • Conditions in programming: if (logged_in && has_permission)
  • Legal formulations: "a fine or imprisonment"
  • Search queries: Google uses AND/OR in different ways

Conjunction: both must be true

**Conjunction** (AND, ∧) is a compound proposition that is true only when **both** simple propositions are true.

**Conjunction notation:** • In logic: P ∧ Q ("P and Q") • In programming: P && Q or P and Q • In mathematics: P · Q • In English: "and", "but" (sometimes), "as well as"

Conjunction is a strict connective. One false component is enough to make the entire proposition false. Like a chain: one weak link - and the whole chain breaks.

"Moscow is the capital of Russia AND Paris is the capital of Germany". This proposition is...

Disjunction: at least one is true

**Disjunction** (OR, ∨) is a compound proposition that is true when **at least one** of the simple propositions is true.

**Note:** In logic "OR" is inclusive. "Sea OR mountains" allows both at the same time! This differs from the everyday "either-or" ("tea or coffee?").

Disjunction is a lenient connective. One true component is enough to make the entire proposition true. Like parallel roads: if at least one is open - traffic flows through.

"2 + 2 = 4 OR the Moon is made of cheese". This proposition is...

Inclusive OR: logic vs everyday language

In logic **OR is always inclusive**: "A or B" is true even if both are true. This often goes against intuition.

**Why inclusive?** It is simpler for mathematics and programming. Most real-world conditions allow both options: "knowledge of Python OR JavaScript" - knowing both is even better!

When people say "OR" in everyday life, they often mean exclusive: "tea or coffee?" - choose one. But in logic the default is inclusive.

"Entry requires a passport OR driver's license". A person presents both documents. Can they enter?

Exclusive OR: one or the other

**Exclusive OR** (XOR, ⊕) is true when **exactly one** of the propositions is true. Both true or both false - the result is false.

**In programming:** • Python: `a ^ b` (for integers) • JavaScript: `a ^ b` • In conditions: `(a || b) && !(a && b)` XOR is used in cryptography, checksums, and toggle switches.

When it matters: "Choose delivery method: courier OR pickup" - this is logically XOR, both cannot be chosen. But the context often makes this implicit.

"A file is open OR closed" - which kind of OR is this?

Truth tables: a cheat sheet for all cases

A **truth table** shows the value of a compound proposition for all possible combinations of values of the simple ones. It is a universal verification tool.

**Why 4 rows?** Two variables × two values = 2² = 4 combinations. For three variables: 2³ = 8 rows. For four: 2⁴ = 16 rows. Tables grow exponentially!

Truth tables are like a calculator for logic. No need to hold everything in mind: just fill in the table and look at the result. In the next lessons we'll build tables for more complex expressions.

"OR" in logic means "one or the other, but not both"

In logic "OR" (∨) is inclusive: it allows both options

Exclusive OR (XOR) is a separate operation. By default in logic and programming OR is inclusive. This simplifies formulas and matches most real-world conditions.

How many rows will a truth table for an expression with 3 variables (P, Q, R) have?

Key Takeaways

  • Conjunction (AND, ∧): true only when BOTH components are true
  • Disjunction (OR, ∨): true when AT LEAST ONE component is true
  • In logic OR is inclusive (allows both options)
  • XOR (exclusive OR): true when EXACTLY ONE is true

Next

Now we'll study the most important connective - the conditional IF-THEN

  • IF-THEN — next lesson
  • Validity — previous lesson

Вопросы для размышления

  • Find conjunctions and disjunctions in the terms of service of some app. Is OR inclusive or exclusive there?
  • How is the difference between AND and OR best explained to a five-year-old?
  • In what situations should a programmer use XOR instead of regular OR?

Связанные уроки

  • comp-18-type-checking
  • ml-01
AND, OR: Combining Propositions

0

1

Sign In