Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 37 Β· Getting Started

What Is Mathematical Logic?

Learn what mathematical logic and set theory study, why programmers need them, and how this course uses runnable Python to make every idea concrete.

Mathematical logic is the study of reasoning itself. Instead of asking "is this number prime?" or "does this loop terminate?", it asks a layer deeper: what counts as a valid argument, what does it mean for a statement to be true, and what can be proved at all? Set theory is its close companion: it gives mathematics a single language of collections, relations and functions in which almost everything else can be written down.

If you write software, you already use this material every day. An if condition is a logical formula. A database query is a statement about sets of rows. A type checker proves small theorems about your program. A SAT solver, a model checker and a proof assistant are all engineered descendants of the ideas in this course.

A note on the runnable code: this course teaches the ideas first and then implements them from scratch in Python, so you can see a truth table, a quantifier or an induction check actually execute. The examples run in your browser with Python 3.14 (Pyodide); nothing is installed.

Four questions that drive the field

Mathematical logic is usually organized around four questions.

  1. Syntax. What do well-formed statements look like? ("p and not q" is a formula; "and p not" is noise.)
  2. Semantics. What does a statement mean, and under which circumstances is it true?
  3. Proof. What counts as a correct derivation of one statement from others?
  4. Limits. Can every true statement be proved? Can a program decide whether a statement is provable?

The first three are the backbone of chapters 1 to 4. The last one is the subject of chapter 7, where we meet completeness, incompleteness and decidability.

Four pillars of logic

Syntax Which strings are formulas
Semantics When a formula is true
Proof Valid steps to a conclusion
Limits What logic cannot do

Syntax is form, semantics is meaning

1 / 2

A first taste: reasoning as computation

Here is a tiny argument. If it rains, the street is wet. It rains. Therefore the street is wet. This argument is valid, and its validity has nothing to do with rain or streets. Replace the facts and the shape survives: if the cache is cold, the request is slow; the cache is cold; therefore the request is slow. Logic studies the shape.

We can check a shape mechanically. Let p stand for "it rains" and q for "the street is wet". The sentence "if p then q" is false only when p is true and q is false. The program below tries every possible assignment of true and false and checks whether any assignment makes the premises true but the conclusion false.

Python Checking an argument shape by brute force

Press Run (or Ctrl + Enter) to see the result here.

Program input Β· what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

No counterexample exists, so the argument shape (called modus ponens) is valid. Notice what we did: we turned "is this argument good?" into a finite search. That is the central trick of propositional logic, and chapter 2 develops it fully.

Why sets belong in the same course

Logic talks about statements; set theory talks about collections. They meet in a simple dictionary: a property defines a set (the set of numbers with that property), "and" corresponds to intersection, "or" to union, "not" to complement, and "implies" to subset. Once you see that dictionary, Venn diagrams and truth tables are two views of the same thing.

Python The logic-sets dictionary

Press Run (or Ctrl + Enter) to see the result here.

Program input Β· what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Python's &, | and <= on sets mirror the logical "and", "or" and "implies". We will make that correspondence precise in sets and logic later in the course.

A short history, in one paragraph

Aristotle catalogued valid argument forms around 350 BCE. In the 1800s Boole turned logic into algebra and Frege invented the modern quantifier notation. Cantor's set theory arrived in the 1870s, and paradoxes found around 1900 (Russell's paradox among them) pushed mathematicians to build rigorous axioms. In 1931 GΓΆdel proved that no consistent, sufficiently strong formal system can prove all truths about the integers, and in 1936 Turing and Church showed there is no algorithm that decides every logical question. The computer you are using is a direct by-product of that work.

How to use this course

  • Read slowly, run everything. Change a premise and predict the result before you run it.
  • Learn the notation as vocabulary. Symbols such as ∧, ∨, Β¬, β†’, βˆ€ and βˆƒ are abbreviations, not magic. Lesson 2 introduces them one at a time.
  • Prove things yourself. Chapter 4 teaches proof techniques; reading proofs is not the same skill as writing them.
  • Expect precision. Logic rewards careful definitions. "Or" in logic is inclusive; "if" does not imply causation. Those small conventions are the price of certainty.

Common misconceptions

  • "Logic is just common sense." Everyday reasoning mixes in context and causation. Formal logic deliberately strips those out, which is why it can be checked by a machine.
  • "A valid argument has true conclusions." Validity is about form: if the premises were true, the conclusion would have to be. A valid argument with a false premise can have a false conclusion.
  • "Set theory is only for mathematicians." Every HashSet, SQL JOIN and type hierarchy is applied set theory.

Check your understanding

Quick check Β· 4 questions

of 4 answered You scored / 4 Β· perfect!

  1. 1. What does the semantics of a logical language describe?

    Syntax decides what is a formula; semantics assigns meaning, that is, truth conditions.
  2. 2. An argument is valid when...

    Validity is a guarantee about form: true premises can never lead to a false conclusion.
  3. 3. In the logic-sets dictionary, which set operation matches logical 'and'?

    x is in A and in B exactly when x is in the intersection of A and B.
  4. 4. Why can propositional validity be checked by a program?

    With n variables there are 2^n assignments, a finite search.

Summary

  • Mathematical logic studies syntax, semantics, proof and the limits of formal reasoning; set theory supplies the shared language of collections.
  • Validity concerns the shape of an argument, not whether its premises happen to be true.
  • Propositional validity is a finite check, which is why it can be automated.
  • Logical connectives and set operations are two views of one idea.
  • This course teaches each concept and then implements it in runnable Python.

Next: Statements, Truth Values and Notation