Fun with Learning Technology
LearnCoursesQuestionsTracksToolsNewsExplorePractice
Fun with Learning Technology

A new problem, explained clearly, every day.

Subscribe
Learn
  • Lessons
  • Topics
  • News
  • Tools
  • Courses
  • Career tracks
  • Everything
Site
  • About
  • Contact
  • Support
  • Privacy
  • Terms
Get the daily one

One email per new problem. No spam.

Request a tutorial

Requests shape what gets made next.

© 2026 Fun with Learning TechnologyRSS
Home›Courses›Reasoning›Introduction to Propositional Logic

Foundations of Reasoning

Introduction to Propositional Logic

Propositional logic is the study of how simple statements can be combined and evaluated to form complex reasoning. It matters because it provides a foundation for structured thinking, enabling you to break down arguments into testable components. You reach for it when analyzing claims, debugging assumptions, or designing systems that require clear, unambiguous rules.

What is a Proposition?

A proposition is a declarative statement that is either true or false, but not both. For example, 'The sky is blue' is a proposition because it can be verified as true or false, whereas 'Close the door' is not a proposition because it is a command. Propositions are the building blocks of propositional logic, as they allow us to work with statements that have definitive truth values. This distinction is crucial because it lets us focus on the content of the statement rather than its form or intent. By limiting ourselves to propositions, we can avoid ambiguity and ensure that our reasoning is grounded in objective truth. For instance, '2 + 2 = 4' is a proposition because it is always true, while 'This is a good movie' is subjective and not a proposition. Understanding propositions is the first step in constructing logical arguments, as they provide the raw material for combining and evaluating ideas.

# Check if a statement is a proposition (simplified example)

def is_proposition(statement):
    # Propositions must be declarative and have a clear truth value
    declarative_keywords = ['is', 'are', 'was', 'were', 'equals', 'has']
    # Commands, questions, or opinions are not propositions
    non_proposition_keywords = ['close', 'open', '?', 'should', 'think']
    
    statement_lower = statement.lower()
    
    # Check for non-proposition indicators
    for keyword in non_proposition_keywords:
        if keyword in statement_lower:
            return False
    
    # Check for declarative structure
    for keyword in declarative_keywords:
        if keyword in statement_lower:
            return True
    
    return False  # Default to False if unsure

# Test cases
print(is_proposition('The sky is blue'))  # True (proposition)
print(is_proposition('Close the door'))   # False (command)
print(is_proposition('Is it raining?'))   # False (question)
print(is_proposition('2 + 2 equals 4'))   # True (proposition)

Logical Connectives: AND, OR, NOT

Logical connectives are the tools that allow us to combine propositions into more complex statements. The simplest connective is NOT, which negates a proposition. For example, if 'It is raining' is true, then 'It is NOT raining' is false. NOT is unary, meaning it operates on a single proposition. The connectives AND and OR are binary, meaning they combine two propositions. AND returns true only if both propositions are true, while OR returns true if at least one of the propositions is true. These connectives are foundational because they mirror how we naturally combine ideas in everyday reasoning. For instance, 'I will go to the park AND it will be sunny' is only true if both conditions are met. Similarly, 'I will eat pizza OR I will eat pasta' is true if either condition is met. Understanding these connectives allows you to model real-world scenarios where multiple conditions must be evaluated together.

# Implementing logical connectives: NOT, AND, OR

def logical_not(p):
    return not p

def logical_and(p, q):
    return p and q

def logical_or(p, q):
    return p or q

# Example propositions
raining = True
sunny = False

# Test NOT
print('NOT raining:', logical_not(raining))  # False

# Test AND
print('Raining AND sunny:', logical_and(raining, sunny))  # False

# Test OR
print('Raining OR sunny:', logical_or(raining, sunny))  # True

# Real-world scenario: 'I will go to the park if it is sunny AND not raining'
will_go_to_park = logical_and(sunny, logical_not(raining))
print('Will go to the park:', will_go_to_park)  # False

Truth Tables: Visualizing Logical Relationships

Truth tables are a systematic way to visualize all possible truth values of a logical statement. They list every combination of truth values for the propositions involved and show the resulting truth value of the entire statement. For example, a truth table for the statement 'P AND Q' would have four rows: one where both P and Q are true, one where P is true and Q is false, one where P is false and Q is true, and one where both are false. The final column would show the result of 'P AND Q' for each combination. Truth tables are invaluable because they reveal the behavior of logical connectives in all possible scenarios, eliminating guesswork. They also help identify edge cases, such as when a statement is always true (a tautology) or always false (a contradiction). By constructing truth tables, you can verify the correctness of logical arguments and ensure that your reasoning holds under all conditions.

# Generate a truth table for a given logical expression

def generate_truth_table(expression, variables):
    from itertools import product
    
    # Header
    header = variables + [expression]
    print(' | '.join(header))
    print('-' * (len(' | '.join(header))))
    
    # Generate all possible truth value combinations
    for values in product([False, True], repeat=len(variables)):
        # Create a dictionary to substitute variable values
        env = dict(zip(variables, values))
        
        # Evaluate the expression
        result = eval(expression, {}, env)
        
        # Print the row
        row = [str(env[var]) for var in variables] + [str(result)]
        print(' | '.join(row))

# Example: Truth table for 'P AND Q'
print('Truth table for P AND Q:')
generate_truth_table('P and Q', ['P', 'Q'])

# Example: Truth table for 'NOT P OR Q'
print('\nTruth table for NOT P OR Q:')
generate_truth_table('(not P) or Q', ['P', 'Q'])

Implication: If-Then Statements

Implication, often written as 'P → Q' and read as 'if P then Q,' is one of the most important but often misunderstood logical connectives. It does not assert that P causes Q, but rather that whenever P is true, Q must also be true. The only time an implication is false is when P is true and Q is false; in all other cases, the implication holds. This can be counterintuitive because we often think of implications as causal relationships. For example, 'If it is raining, then the ground is wet' is an implication that is only false if it is raining and the ground is not wet. If it is not raining, the implication is still true regardless of whether the ground is wet or dry. Implication is crucial in reasoning because it allows us to express conditional relationships, such as rules, promises, or hypotheses. Understanding implications helps you avoid logical fallacies, such as assuming that 'P → Q' means 'Q → P' (the converse) or 'NOT P → NOT Q' (the inverse).

# Implementing implication (P → Q) and testing its truth table

def implies(p, q):
    # P → Q is equivalent to (NOT P) OR Q
    return (not p) or q

# Test cases for implication
print('P → Q (P=True, Q=True):', implies(True, True))   # True
print('P → Q (P=True, Q=False):', implies(True, False)) # False
print('P → Q (P=False, Q=True):', implies(False, True))  # True
print('P → Q (P=False, Q=False):', implies(False, False)) # True

# Real-world example: 'If it is raining, then the ground is wet'
raining = True
ground_wet = False
print('\nImplication holds:', implies(raining, ground_wet))  # False (raining but ground not wet)

Logical Equivalence and Tautologies

Logical equivalence occurs when two statements always have the same truth value, regardless of the truth values of their constituent propositions. For example, 'P → Q' is logically equivalent to '(NOT P) OR Q,' as both statements yield the same results in all possible scenarios. Tautologies are statements that are always true, no matter the truth values of their propositions. For instance, 'P OR NOT P' is a tautology because it is true whether P is true or false. Recognizing logical equivalence and tautologies is essential because it allows you to simplify complex statements and identify redundant or unnecessary conditions. For example, if you encounter the statement '(P AND Q) OR (P AND NOT Q),' you can simplify it to just 'P' because the two sub-statements are mutually exclusive and cover all possibilities for Q. Similarly, tautologies can be used to verify the validity of arguments, as any argument that results in a tautology is inherently valid.

# Checking logical equivalence and tautologies

def is_equivalent(expr1, expr2, variables):
    from itertools import product
    
    for values in product([False, True], repeat=len(variables)):
        env = dict(zip(variables, values))
        if eval(expr1, {}, env) != eval(expr2, {}, env):
            return False
    return True

def is_tautology(expression, variables):
    from itertools import product
    
    for values in product([False, True], repeat=len(variables)):
        env = dict(zip(variables, values))
        if not eval(expression, {}, env):
            return False
    return True

# Test logical equivalence: P → Q vs (NOT P) OR Q
print('P → Q is equivalent to (NOT P) OR Q:', 
      is_equivalent('(not P) or Q', 'implies(P, Q)', ['P', 'Q']))  # True

# Test tautology: P OR NOT P
print('P OR NOT P is a tautology:', 
      is_tautology('P or (not P)', ['P']))  # True

# Simplify (P AND Q) OR (P AND NOT Q) to P
print('(P AND Q) OR (P AND NOT Q) is equivalent to P:', 
      is_equivalent('(P and Q) or (P and (not Q))', 'P', ['P', 'Q']))  # True

Key points

  • A proposition is a declarative statement that can be definitively classified as true or false, forming the basic unit of propositional logic.
  • Logical connectives like AND, OR, and NOT allow you to combine propositions into more complex statements, enabling structured reasoning.
  • Truth tables provide a complete visualization of all possible truth values for a logical statement, ensuring no edge cases are overlooked.
  • Implication (P → Q) is only false when P is true and Q is false, and it does not imply causation between P and Q.
  • Logical equivalence means two statements always yield the same truth value, allowing you to simplify or transform expressions without changing their meaning.
  • Tautologies are statements that are always true, regardless of the truth values of their components, and are useful for validating arguments.
  • Understanding propositional logic helps you break down arguments into testable components, avoiding ambiguity in reasoning.
  • Mastering these concepts enables you to analyze claims, debug assumptions, and design systems with clear, unambiguous rules.

Common mistakes

  • Mistake: Confusing 'if P then Q' with 'P only if Q'. Why it's wrong: 'If P then Q' (P → Q) means Q is necessary for P, but 'P only if Q' means Q is sufficient for P, which is logically equivalent to Q → P. Fix: Remember that 'if' introduces the antecedent (P), while 'only if' introduces the consequent (Q).
  • Mistake: Treating 'P unless Q' as equivalent to 'P or Q'. Why it's wrong: 'P unless Q' is logically equivalent to 'if not Q then P' (¬Q → P), which is the same as 'P or Q' (¬Q ∨ P), but the intuitive interpretation often leads to errors in complex statements. Fix: Always rewrite 'P unless Q' as '¬Q → P' to avoid confusion.
  • Mistake: Assuming that 'P and Q' implies 'P or Q' is always true. Why it's wrong: While 'P and Q' does imply 'P or Q', the reverse is not true. This mistake often arises when confusing the direction of implication. Fix: Remember that 'P and Q' is a stronger statement than 'P or Q' and does not follow from it.
  • Mistake: Misapplying De Morgan's laws by distributing negation incorrectly. Why it's wrong: A common error is to write ¬(P ∧ Q) as ¬P ∧ ¬Q instead of ¬P ∨ ¬Q, or ¬(P ∨ Q) as ¬P ∨ ¬Q instead of ¬P ∧ ¬Q. Fix: Practice rewriting negations of compound statements using De Morgan's laws until it becomes intuitive.
  • Mistake: Believing that 'P → Q' is equivalent to 'Q → P'. Why it's wrong: This is the converse fallacy. The implication 'P → Q' is not logically equivalent to its converse 'Q → P'. Fix: Remember that the truth table for 'P → Q' is only false when P is true and Q is false, while 'Q → P' has a different truth table.

Interview questions

What is propositional logic, and why is it fundamental in reasoning?

Propositional logic is a branch of formal logic that deals with propositions—statements that can be either true or false—and the logical relationships between them using connectives like AND, OR, NOT, IMPLIES, and IF AND ONLY IF. It is fundamental in reasoning because it provides a structured way to analyze arguments, determine validity, and model real-world scenarios where truth values matter. For example, in computer science, propositional logic underpins circuit design, where logical gates correspond to these connectives. Without it, we couldn’t systematically verify whether a conclusion follows from premises, which is essential for fields like mathematics, philosophy, and artificial intelligence.

Explain the difference between a tautology and a contradiction in propositional logic. Provide an example of each.

A tautology is a proposition that is always true, regardless of the truth values of its components. For example, the statement 'P OR NOT P' is a tautology because, no matter whether P is true or false, the entire statement evaluates to true. A contradiction, on the other hand, is a proposition that is always false, such as 'P AND NOT P.' Here, the statement cannot be true under any assignment of truth values to P. Tautologies are useful for proving logical truths, while contradictions help identify impossible scenarios. In reasoning, recognizing these helps simplify complex expressions and validate arguments.

How do you construct a truth table for a compound proposition? Walk through the process for the expression '(P AND Q) IMPLIES R'.

To construct a truth table for '(P AND Q) IMPLIES R,' start by listing all possible truth value combinations for P, Q, and R. Since there are three variables, there are 2^3 = 8 rows. First, evaluate 'P AND Q' for each row, which is true only when both P and Q are true. Next, evaluate the implication '(P AND Q) IMPLIES R,' which is false only when the antecedent (P AND Q) is true and the consequent (R) is false. For example, if P=True, Q=True, and R=False, the implication is false. Otherwise, it’s true. The truth table systematically shows how the compound proposition behaves for every input combination, which is critical for verifying logical equivalence or validity.

Compare the use of natural deduction and truth tables for proving logical validity. Which approach is better for large propositions, and why?

Natural deduction and truth tables are both methods for proving logical validity, but they differ in approach and scalability. Truth tables enumerate all possible truth value combinations, making them straightforward but impractical for large propositions because the number of rows grows exponentially with variables (e.g., 10 variables require 1,024 rows). Natural deduction, however, uses inference rules like modus ponens or conjunction elimination to derive conclusions step-by-step, which is more efficient for complex arguments. While truth tables are exhaustive and easy to verify, natural deduction mirrors human reasoning and scales better. For large propositions, natural deduction is preferable because it avoids combinatorial explosion and focuses on relevant logical steps.

What is the principle of explosion in propositional logic, and how does it relate to contradictions? Provide a formal example.

The principle of explosion states that from a contradiction, any arbitrary proposition can be derived. In formal terms, if you assume 'P AND NOT P' (a contradiction), you can prove any statement Q. This is because a contradiction implies everything—there’s no consistent way to assign truth values, so the system 'explodes' into triviality. For example, using the contradiction 'P AND NOT P,' you can derive Q via disjunction introduction: from 'P,' infer 'P OR Q,' then use 'NOT P' to eliminate P, leaving Q. This principle highlights why contradictions are problematic in reasoning—they render a logical system useless by allowing any conclusion, regardless of relevance. It underscores the importance of consistency in formal systems.

Explain how propositional logic can be used to model real-world decision-making. Provide a concrete example where logical equivalence simplifies a problem.

Propositional logic models real-world decision-making by representing choices and constraints as propositions and connectives. For example, consider a scenario where you decide whether to attend an event based on two conditions: 'If it rains (R), I’ll go only if I have an umbrella (U),' and 'I’ll go (G) if it’s sunny (NOT R).' This can be written as '(R IMPLIES (G IF AND ONLY IF U)) AND (NOT R IMPLIES G).' To simplify, we can use logical equivalence to rewrite the expression. For instance, 'R IMPLIES (G IF AND ONLY IF U)' is equivalent to '(R AND U) IMPLIES G OR (R AND NOT U) IMPLIES NOT G.' This simplification clarifies the conditions under which G is true, making the decision easier to evaluate. Such modeling is used in automated reasoning, like AI planning or circuit optimization, where logical equivalence reduces complexity.

All Reasoning interview questions →

Check yourself

1. Which of the following is logically equivalent to 'If it rains, then the ground is wet'?

  • A.If the ground is not wet, then it did not rain
  • B.If the ground is wet, then it rained
  • C.The ground is wet only if it rains
  • D.It rains if and only if the ground is wet
Show answer

A. If the ground is not wet, then it did not rain
The correct answer is 'If the ground is not wet, then it did not rain' because it is the contrapositive of the original statement (¬Q → ¬P is equivalent to P → Q). The other options are incorrect: the second is the converse (Q → P), the third is equivalent to Q → P, and the fourth is a biconditional (P ↔ Q), which is stronger than the original implication.

2. Consider the statement 'You can pass the course only if you submit all assignments.' Which of the following correctly represents this statement?

  • A.If you pass the course, then you submitted all assignments
  • B.If you submit all assignments, then you pass the course
  • C.You pass the course if and only if you submit all assignments
  • D.You pass the course or you submit all assignments
Show answer

A. If you pass the course, then you submitted all assignments
The correct answer is 'If you pass the course, then you submitted all assignments' because 'P only if Q' is logically equivalent to P → Q. The other options are incorrect: the second is the converse (Q → P), the third is a biconditional (P ↔ Q), and the fourth is a disjunction (P ∨ Q), which is not equivalent.

3. What is the negation of the statement 'Either the battery is dead or the screen is broken'?

  • A.The battery is not dead and the screen is not broken
  • B.The battery is dead and the screen is broken
  • C.The battery is not dead or the screen is not broken
  • D.Neither the battery is dead nor the screen is broken
Show answer

A. The battery is not dead and the screen is not broken
The correct answer is 'The battery is not dead and the screen is not broken' because the negation of 'P ∨ Q' is '¬P ∧ ¬Q' (De Morgan's law). The other options are incorrect: the second is the conjunction of P and Q, the third is the disjunction of ¬P and ¬Q, and the fourth is equivalent to the first but less precise in logical terms.

4. Which of the following statements is logically equivalent to 'It is not the case that both the light is on and the door is closed'?

  • A.The light is off or the door is open
  • B.The light is off and the door is open
  • C.If the light is on, then the door is open
  • D.The light is on or the door is closed
Show answer

A. The light is off or the door is open
The correct answer is 'The light is off or the door is open' because the negation of 'P ∧ Q' is '¬P ∨ ¬Q' (De Morgan's law). The other options are incorrect: the second is the conjunction of ¬P and ¬Q, the third is an implication (P → ¬Q), and the fourth is a disjunction (P ∨ Q), which is not equivalent.

5. Suppose 'If the alarm rings, then there is a fire' is true. Which of the following must also be true?

  • A.If there is no fire, then the alarm does not ring
  • B.If the alarm does not ring, then there is no fire
  • C.The alarm rings if and only if there is a fire
  • D.There is a fire only if the alarm rings
Show answer

A. If there is no fire, then the alarm does not ring
The correct answer is 'If there is no fire, then the alarm does not ring' because it is the contrapositive of the original statement (¬Q → ¬P is equivalent to P → Q). The other options are incorrect: the second is the inverse (¬P → ¬Q), which is not equivalent; the third is a biconditional (P ↔ Q), which is stronger; and the fourth is equivalent to Q → P, the converse.

Take the full Reasoning quiz →

← PreviousThe Role of Assumptions in ReasoningNext →Truth Tables and Logical Connectives

Reasoning

36 lessons, free to read.

All lessons →

Track your progress

Sign in to mark lessons done, score quizzes and keep notes.

Open in the app