Lesson 1
Introduction to Logic
Taught
Symbols, Logic and Language
Logic is the language of mathematics. It restricts our focus to statements that are definitively true or false, thereby making human language precise. This formalisation resolves inherent ambiguities when interpreting natural expressions such as “if … then,” “or,” and “and.”
Early Greek philosophers, notably Aristotle and Chrysippus, laid the initial formal foundations but frequently struggled with the precise boundaries of semantics. It was not until the work of modern mathematicians such as Leibniz (1666), Boole (1847) and De Morgan (1847) that propositional logic was formalised.
This development introduced the core architecture of modern mathematics: formal languages, variables, operators, axioms, logical inference and proof.
Syntax and Semantics
Because logic is the formal language of mathematics, it possesses two fundamental aspects. The grammatical rules governing how symbols may be validly composed dictate its syntax, while the meaning behind a particular arrangement of those symbols is its semantics.
In mathematics, we refer to objects by giving them names. A variable is a symbol that stands in for an object that has not yet been specified. We assign a name to a particular object using the assignment operator . For example, writing assigns the value to the variable . We can similarly define the golden ratio as
The objects and variables within an expression are its terms. For instance, , , and are all distinct terms.
Remark (On Notation).
Variables are typically denoted using single Latin or Greek letters. Common choices include:
- Lowercase:
- Uppercase:
- Greek:
Propositions and Truth Values
Mathematics, in its most basic form, is the practice of assigning truth to well-defined statements; it differs from other sciences in that its results are proven rigorously, as opposed to being hypothesized and then “confirmed” via experiements.
For these notes, most of our work amounts to taking a collection of statements which we already know to be true and using them to establish newer, more complex ones, or formulating statements whose truth or falsity we wish to determine. If we were to encounter a falsity, we would have to demonstrate that it is indeed false; so, we begin with the logic that connects what we know to what we wish to know.
The statements mathematicians study are called logical or mathematical statements or propositions, which we define as follows:
A proposition is a grammatically correct declarative sentence that has a definite truth value.
By “grammatically correct,” we just mean that the words and symbols follow the rules of English (or any language you speak), and make sense.
The truth value of a proposition indicates whether the proposition is true or false. We abstract away the specific content of a statement to focus solely on its logical status, denoting ‘true’ with the symbol (read “top”) and ‘false’ with the symbol (read “bot” or “bottom”).
The foundation of classical logic rests on the principle of bivalence, which states that every proposition is either true or false, but not both.
Some basic examples include:
- . (Truth value: )
- The integer 7 is even. (Truth value: )
- For any real number , . (Truth value: )
- Every even integer greater than 2 can be written as the sum of two prime numbers. (Truth value: unknown)
- The Earth is round. (Truth value: )
Example 4 is something to note: by the principle of bivalence, a sentence need not have a known truth value to qualify as a proposition; all that matters is that it makes logical sense to assign one; in fact, although the truth value of many propositions remains unknown, they are still valid propositions.
Remark.
Propositions like Example 4 are called conjectures, with Example 4 being known as the Goldbach Conjecture; in general, a conjecture is a claim believed to be true but which has not yet been proved or disproved.
By the principle of bivalence, we also see that many mathematical expressions and sentences are not propositions because they lack a definite truth value — imperative sentences (commands) and interrogative sentences (questions), for example, are naturally excluded.
The following are not propositions:
- . (This is a term. Its value depends on , but it is not a complete sentence capable of carrying a truth value.)
- Solve the equation . (An imperative command.)
- Is a rational number? (An interrogative question.)
- . (This is something called an open sentence, but its truth value depends on the unspecified variable . It is a predicate, which will be addressed in later sections.)
Suppose we say “Every even number greater than 2 can be written as the sum of two primes.” Is this a proposition?
Semantically Void and Self-Contradictory Sentences
Consider the following sentence: “The theory of relativity eats breakfast loudly.” Although it possesses a subject, verb, and adverb, the problem is that a scientific theory is an abstract concept which cannot eat; thus, because it describes a nonsensical scenario, there is no sensible way to assign a truth value to it — assigning is absurd, while assigning would require that “The theory of relativity does not eat breakfast loudly” is a true statement, which is equally bizarre.
A more subtle challenge arises from paradoxes: sentences that are semantically meaningful but inherently are self-contradictory. Consider a page containing only the following sentence:
“The only proposition on this page is false.”
Attempting to assign a truth value to this sentence, denoted by , yields a contradiction:
- If is : Then the sentence asserts that is false; since it is the only proposition present, must evaluate to , contradicting our initial assumption that is true.
- If is : Then the sentence’s assertion that the only proposition on the page is false must itself be false. Since is the only proposition on the page, must therefore evaluate to , contradicting our initial assumption that is false.
Hence, as the sentence cannot be assigned a truth value, it is not a proposition.
What happens if we do allow sentences like this to count as proper mathematical statements? What if we abandon the requirement that every statement we care about must be either true or false — is something fundamentally wrong, or have we simply entered a different logical universe?
In general, self-referential sentences like the one above, are quite bizarre and can produce some paradoxes that we want to disallow. By narrowing our scope strictly to propositions, we guarantee that our logical framework remains consistent, and most importantly suitable for automated reasoning and algorithmic verification (yes this is about Lean).
Construct an example of a true proposition, a false proposition, a proposition whose truth value you do not currently know, a paradox, and a mathematical statement that is not a proposition.
Atomic Statements and the Structure of Mathematical Truth
To analyse complex (or compound) statements, we decompose them into their foundational components.
Definition 1.5 (Atomic Statement).
A statement is called atomic (or an atomic proposition) if it cannot be broken down into simpler constituent propositions.
For example, “5 is a prime number” is an atomic statement. Conversely, “5 is a prime number and 4 is an even number” is a complex statement built from two atomic components.
Remark.
We traditionally express these base components using propositional variables, denoted by lowercase letters such as .
By combining atomic statements into more complex structures, we can construct rigorous arguments in which certain statements support another, leading to the core mechanism of mathematics: proof.
A proof of a proposition is a verified logical argument demonstrating its truth. It must begin from known or assumed truths, proceed via agreed-upon valid logical steps, and be entirely verifiable by a knowledgeable reader.
As we build this mathematical architecture, the results we prove will be categorised by their structural role and intended usage:
- Proposition: In addition to its logical meaning above, “proposition” is also commonly used as a label for a proved result, usually one of lesser or supporting importance than a theorem.
- Theorem: A significant mathematical result.
- Corollary: A result that follows as an immediate logical consequence of a theorem or proposition.
Logical Connectives
Thus far, we have mostly been working with atomic propositions; the next step is to combine statements into new statements using logical operators or connectives, where the truth value of the combined statement is based solely on the truth values of the original statements and on the type of logical operator facilitating the combination. These rules should make sense to you based on your understanding of the English language as a whole, but we also define them using a truth table (a table whose columns correspond to mathematical statements and their respective truth values), which lists the output truth value for every possible combination of truth values assigned to the input propositional variables.
Negation
The simplest logical operator is the negation operator, which produces the “opposite” of the original statement in the logical sense. It is actually a so-called unary operator, i.e., it does not combine statements but is merely applied to one statement. If is a statement, its negation, written , is the statement with the exact opposite truth value, usually produced by placing a “not” in the grammatically appropriate spot. For example, if is the statement “Jack is a boy,” then is the statement “Jack is not a boy,” or for another example if is the statement “31 is a prime number” (), then is the statement “31 is not a prime number” or, equivalently, “31 is composite” ().
We negated “31 is prime” to “31 is composite.” Does swapping “not prime” for “composite” work for every natural number, or did 31 get lucky?
Compound Sentences
Having seen how a unary operator acts on a single statement, we now proceed to binary logical operators, i.e., logical operators combining precisely two statements. Given two statements and , we can join them with an “and” or an “or” to build a complex statement whose truth value depends, in the way you would expect, on the truth values of and .
The conjunction of and , read ” and ” and written , is true precisely when both pieces are true, and false otherwise.
Let be the proposition “2+3=5,” be the proposition “There exists a prime number greater than ,” and the statement “the sky is red.” Thus, because both are true, their conjunction is true. Pairing with instead gives ” and the sky is red.” Here the first piece is true and the second is false, so is false.
Remark.
In English, conjunctions are frequently expressed using words such as “but,” “yet,” “while,” or “moreover.” The statement “A square has four sides, but a triangle has three vertices” serves the exact same logical function as a formal “and” statement.
The disjunction of and , read ” or ” and written , is true if at least one of the component propositions is true, and evaluates to false only when both and are false.
Since both may hold at once, our “or” is what computer scientists call an inclusive or. The exclusive or, also known as XOR, on the other hand, denoted , evaluates to if exactly one of or is .
Reusing our definitions of in the example block above, is true, is true, but is false.
Remark (On Ambiguity).
In everyday English, “or” is heavily context-dependent. The statement “Candidates must have a degree in mathematics or computer science” implies an inclusive or, as possessing both degrees is entirely acceptable. However, being offered “soup or a salad” with a meal implies an exclusive or, where choosing both is not an option. In mathematics, “or” strictly denotes the inclusive disjunction unless specified otherwise.
Suppose is while is . What do you know about and ?
As you will have noted in the stated examples, logical operators can combine statements even when their meanings do not seem directly connected. While this might seem strange, adding restrictions based on content is neither needed nor helpful, because statements that appear unrelated can later become relevant within the same context. The same point applies to implications and equivalences, where the connection may initially seem even less intuitive.
”If-Then” Statements
Most statements we meet in these notes arrive as “If , then .” These are the conditional statements (or implications), written (or ) and read ” implies ”; within one, is called the hypothesis (or premise) and the conclusion. The logic of the implication is usually a little bit counter-intuitive to beginners so to be extra careful we can think of the statement to mean the same thing as “whenever is true, is also true”; i.e., evaluates to in only one scenario: when is but is .
Remark.
The key word here is “whenever”: claims that every situation in which is true is also one in which is true, so a situation where is false cannot violate the implication, regardless of the truth value of .
Consider the statement: “If the employee finishes the project by Friday (), then they will receive a bonus ()”:
- If is , is : The employee finishes on time and gets the bonus.
- If is , is : The employee finishes on time, but does not receive the bonus. This contradicts the promise, so the statement is .
- If is , is : The employee misses the deadline but receives a bonus anyway (perhaps for previous good work). The original statement only specified what happens if the project is finished on time; it did not prohibit a bonus otherwise. The statement remains true.
- If is , is : The employee misses the deadline and receives no bonus. The statement remains true.
Cases 3 and 4 illustrate what is known as a vacuous truth: whenever the hypothesis is , the implication places no restriction on the conclusion and therefore evaluates to automatically.
“If , then 7 is prime” — true or false? What about “If , then 7 is composite”?
I promise: “if it rains, I bring an umbrella.” You catch me carrying one under a cloudless sky. May you call me a liar?
Another bit of confusion with these kind of statements comes from the word “implies,” as some use the word to convey some kind of causality. Take, for example the statement ” implies ,” which is a true statement; many implications seem to follow this pattern, where the truth of the hypothesis seems to lead us to the truth on the conclusion, but this isnt the case in general!
Another example, “the sky being blue implies ,” is a true statement, despite the color of the sky having nothing to do with equaling 4; thus, the truth of , depends only on the truth values of and , regardless of if we can deduce the conclusion directly from the hypothesis (or if any meaningful connection between either even exist).
Granted, the implication is not really useful in situations, where the truth values of both and are already known; that is in a typical application, one tries to establish the truth of to prove the truth of (a strategy that will fail if happens to be false); it is important to keep in mind, that this is a consequence of the strategy not an undelying part of how conditional statements are defined.
Finally, like conjuction, there are a plethora of ways to express implication in english; consider the implication , where is “It is raining” and is “The ground is wet,” assuming the implication evaluates to , one may also say:
- If it rains, then the ground is wet.
- The ground being wet is a consequence of it raining.
- From “it is raining,” one may infer “the ground is wet.”
- It raining is sufficient for the ground to be wet.
- The ground being wet is necessary for it to rain.
- It rains only if the ground is wet.
The connectives introduced above are the standard primitives of propositional logic, but classical logic requires even fewer primitives than just these; in fact, every logical connective can be expressed using only negation and disjunction. Using this fact, express , and , only with and , and verify each expression using a truth table. Can you find more than one expression for any of them?
Operator Precedence
Finally, before concluding this section, to preserve clarity and avoid an unreadable accumulation of parentheses in complex expressions, logical connectives adhere to a strict order of precedence. Operations are evaluated in the following hierarchy:
- Negation,
- Conjunction,
- Disjunction,
- Implication,
Under these rules, compound propositions are implicitly bracketed. For example, logical equivalence allows us to interpret expressions unambiguously without superfluous parentheses; is the same as ; likewise, means .
Remark.
The exclusive or lacks a universally standardised precedence level within this hierarchy; consequently, parentheses must always be explicitly written when incorporating it into compound statements.
Consider the unparenthesised propositional formula . First, rewrite this formula with all implicit parentheses explicitly shown, adhering strictly to the operator precedence hierarchy. Second, determine the final truth value of the formula given the assignment where is , is , and is .
While multiplication distributes over addition (), addition does not distribute over multiplication in real numbers. Provide an explicit counterexample showing that .
The Structure of Proof Systems
Having established a language of propositions, connectives, and truth tables, the natural question is: what can we actually do with all of this?
Although truth tables answer individual questions, they have several problems, one being that brute-force enumeration of every possible assignment scales poorly: a formula with atomic variables needs rows (quite obvious to see). Another, more fundamental, problem is that a truth table tells us that something is true without revealing why it is true, or how its truth connects to anything else. To patch this, we build what is called a proof system.
Formally, a proof system — pioneered by Gottlob Frege in 1879 — is a mechanism that uses axioms (assumed truths) and inference rules to mechanically derive new valid statements from existing ones. To achieve this, the system operates on two fundamental objects: statements (finite symbol strings expressing propositions) and proofs (the formal sequences justifying them). The relationship between these objects is governed by two rules:
- Semantics (Truth): A rule determining whether a given statement is true or false (the previous section used truth tables).
- Verification (Syntax): A procedure that decides if a specific string constitutes a valid proof for a given statement. This verification must be efficiently computable; a proof whose validity cannot be checked in reasonable time is useless.
The ultimate goal of a proof system is to align these two sides — ensuring that syntactic provability mirrors semantic truth. We measure this alignment through two key properties: Soundness: If a statement has a valid proof, it is true (no false statement possesses a valid proof) and Completeness: If a statement is true, a valid proof for it exists.
Remark (On Computational Efficiency).
In contrast to truth tables, verifying a formal proof requires only line-by-line pattern matching against inference rules, taking time proportional to the length of the proof itself. This fundamental asymmetry (that verifying a proof is computationally cheap even if finding one is hard) is the cornerstone of modern logic and computational complexity theory.
Consider statements of the form “The integer is composite.”
- Semantics: The statement is true if has a divisor such that .
- Proof: A valid proof could simply be the divisor itself.
- Verification: Divide by and check whether the remainder is zero.
The verification step is computationally cheap, even when finding the divisor is extraordinarily difficult.
Satisfiability
Before constructing proofs, we must classify propositions by the range of truth values they can assume. Not all compound propositions behave alike: some are always true, some are always false, and some depend on the assignment.
A compound proposition is a tautology if it evaluates to under every possible assignment of truth values to its atomic variables.
Definition 1.13 (Contradiction).
A compound proposition is a contradiction if it evaluates to under every possible assignment of truth values to its atomic variables.
Definition 1.14 (Contingency).
A compound proposition is a contingency if it is neither a tautology nor a contradiction; its truth value depends on the specific assignment.
A proposition is satisfiable if there exists at least one assignment under which it evaluates to . Every tautology and every contingency is satisfiable. A contradiction is unsatisfiable.
The proposition is a tautology (by the principle of bivalence, one of or must hold). The proposition is a contradiction. The bare variable is a contingency.
To establish that a proposition is satisfiable, a single witness assignment suffices. To establish that it is unsatisfiable, one must check every assignment, which is precisely the expensive enumeration that motivates the algebraic approach developed below.
Determine the satisfiability of . If satisfiable, provide a witness assignment. If unsatisfiable, justify your answer.
Logical Equivalence and Nonequivalence
Next, we need a way to decide when two statements are actually “the same,” at least in terms of their truth values. In particular, we may be able to prove that two statements have the same truth value for every possible assignment of the variables they contain.
From the logical operations and negation we can assemble statements of considerable complexity. Consider the formula
This is a disjunction of three terms; by the associativity of (which we will prove shortly), the parentheses around the disjunction are irrelevant, and thus the formula is true exactly when at least one of the negated conjunctions is true. Now compare it with the much simpler expression . Even a quick glance suggests they both express “at least one of is false.” Their truth tables confirm this equivalence in a single combined table:
The two formulas agree on every row. This phenomenon deserves a name.
Definition 1.16 (Logical Equivalence).
Let and be statements built from the same simpler statements using , and . They are logically equivalent, written , if every assignment of truth values to those simpler statements gives and the same value.
We can express this “same truth value” agreement directly in the language with a single connective.
Biconditional
Let and be statements, the biconditional, (read ” if and only if ,” frequently abbreviated as “iff”) describes a relationship where two propositions strictly share the same truth value. For example, “A polygon is a triangle () if and only if it has exactly three sides ().” If one is true, the other must be true; if one is false, the other must be false. Also note that when dealing with a biconditional , the proposition is said to be “necessary and sufficient” for .
Equivalently, asserts both []. If is true, then forces to be true; if is false, then forces to be false. Thus, in either case, and have the same truth value.
Show using a truth table that and [] have the same truth values for every possible truth.
The biconditional gives us a convenient way to characterize logical equivalence. For any particular assignment, tells us whether and agree under that assignment. If they agree under every assignment, then the biconditional is always true.
Remark (Equivalence via Biconditional).
Equivalence can also be expressed in terms of a tautology: This will be especially useful when we work algebraically, because it allows us to replace by the statement that reduces to .
The opposite situation is equally important.
Definition 1.17 (Logical Nonequivalence).
Two statements and are not logically equivalent, written , if there exists at least one assignment of truth values to their variables for which their resulting truth values differ. Such an assignment is termed a counterexample.
And thus finally, we now have all the tools to build a proof system.
Equivalence Proofs
We now introduce the axiomatic foundation that allows us to reason about propositional equivalences without enumerating truth tables. The axioms of classical propositional logic specify the algebraic behaviour of the connectives , , and . Each axiom is a logical equivalence, asserting that two expressions are interchangeable in all contexts. The first five axiom pairs define a structure known as a Boolean algebra.
The axioms govern only , , and . To bring and within their reach we use the defining equivalences of the two conditional connectives, which rewrite them in terms of the core trio:
Feel free to pick any three axioms and prove them using a truth table.
From these axioms, we derive theorems. Recall Definition 1.6 : a proof begins from known truths and proceeds via valid logical steps. An equivalence proof is a chain of equivalences, each justified by an axiom, a definition, or a previously established theorem:
The astute might ask: what logically permits us to stitch individual equivalences together into a single chain? Well this method relies on the principle of transitivity; we first show by truth table the closely related transitivity of implication, and then verify the transitivity of equivalence.
Let and be any propositions. We show that the transitivity of implication, , is a tautology.
The final column is in every row, so the formula is a tautology. Similarly, for any propositions and , we show that the transitivity of equivalence, , is also a tautology.
By the truth table, the transitivity of equivalence is likewise a tautology, fully justifying the chain-of-equivalences method. This method is vastly more efficient than truth tables for complex formulas (as we see below), though it requires algebraic ingenuity rather than mechanical enumeration.
Fundamental Theorems
Theorem 1.18 (Uniqueness of Complements).
For any propositions and , if and , then .
Proof.
Let and be arbitrary propositions satisfying and . We show that both and reduce to the same expression. First:
Similarly:
Both and equal , hence .
Remark.
The symbol at the end of a proof is a modern substitute for the traditional Q.E.D., an initialism for the Latin phrase quod erat demonstrandum, meaning “what was to be shown.”
This theorem is the engine behind nearly every derivation that follows. It tells us that if something behaves like a complement (annihilates under , completes under ), then it is the complement. We now put it to work.
and .
Proof.
By Identity, . By Commutativity and Identity, . The premises of Theorem 1.18 are satisfied with and , yielding . The second statement follows identically with , .
Corollary 1.20 (Negative Equivalence).
For any propositions and , if , then .
Proof.
Let . Then: and
By Theorem 1.18 (with playing the role of and playing the role of ), we conclude .
For any propositions such that and :
The proofs are straightforward applications of substitution and are left for the reader.
With Theorem 1.18 and its corollaries established, we can now derive the classical theorems of propositional logic.
Theorem 1.22 (Double Negation).
For any proposition , .
Proof.
By Complement (and Commutativity): and . The premises of Theorem 1.18 are met with in the role of and in the role of . Therefore .
For any proposition , and .
Proof.
For the conjunctive case:
The disjunctive case follows analogously:
For any proposition , and .
Proof.
For the disjunctive fragment:
The conjunctive fragment:
For any propositions and , and .
Proof.
For the disjunctive case:
The conjunctive case:
Theorem 1.26 (De Morgan's Laws).
For any propositions and , and .
Proof.
We prove by applying Theorem 1.18 . We must show and .
The conjunctive branch:
By Theorem 1.18 , . The proof of is analogous.
Prove by equivalence proof that (the second De Morgan’s Law).
Of course De Morgan’s Laws are not isolated identities; they are the first manifestation of a much broader symmetry between conjunction and disjunction. This relationship is captured by the notion of logical duality.
Definition 1.27 (Logical Duality).
Two binary logical connectives are dual when negating a compound expression built from one connective yields a formula that is logically equivalent to the compound expression built from the other connective, but with the inputs themselves negated.
Remark (Principle of Duality).
More generally, for any equivalence involving only , , and , swapping every with (and every with ) produces another valid equivalence. This is the Principle of Duality for Boolean algebra.
Conjunction and disjunction are the fundamental dual pair of classical logic. The two De Morgan’s Laws show exactly that and are dual to each other: negating an AND gives an OR of the negated parts, and negating an OR gives an AND of the negated parts.
Using this we extend the De Morgan’s Laws extend naturally to any finite number of propositions.
For any propositions , and
Proof.
Since and are dual, negating a conjunction exchanges for while negating each of its components; hence By the same duality, negating a disjunction exchanges for , giving
Show that is a tautology, without using a truth table.
Equivalences Involving Conditionals
The defining equivalences of and allow us to derive every conditional equivalence by reducing implications to and applying the theorems above:
Notice the pattern in the implication equivalences: when implications share the same premise, the conclusions combine with the same connective ( or ). When they share the same conclusion, the premises combine with the opposite connective. This “flip” from to (and vice versa) is a direct consequence of the hidden negation in the definition of : the antecedent of an implication sits behind a , so De Morgan’s Laws invert the connective when premises are merged.
Contrapositive, Converse, and Inverse
Let and be mathematical statements. From an implication , three related conditionals arise:
- The contrapositive .
- The converse .
- The inverse .
Something hinted at so far is that the direction of an implication matters: in general, reversing an implication does not preserve its truth. That is, even if is true, its converse need not be true.
Using an equivalence proof, show that and
The first equivalence is particularly important. Since if we wish to prove , we may instead show and this technique is one of the most useful methods of proof in mathematics (we see more of it later). However, because the converse is not determined by the truth value of the original implication whenever a mathematician proves a statement of the form , a natural follow-up question is whether the converse also happens to hold. This distinction is also the source of a common logical fallacy: Suppose we have established that ; someone might object that does not necessarily imply , and therefore claim that the original argument is wrong, however, this objection confuses an implication with its converse.
Negating Conditional Statements
For the end of this specific section we ask: what does it mean for an implication itself to be false?
Recall that fails in exactly one situation: when is true and is false; expressing this algebraically using the conditional equivalence:
Theorem 1.29 (Negation of a Conditional).
For any propositions and ,
Proof.
This has a useful interpretation: to show that an implication is false, one must exhibit a case in which the hypothesis holds but the conclusion fails. In other words, a counterexample to an implication is precisely a witness to . It is worth distinguishing this from several superficially similar statements: neither nor is the negation of . Anyway, we can negatate the biconditional similarly.
Theorem 1.30 (Negation of a Biconditional).
For any propositions and ,
Prove the above theorem.
Thus, a biconditional is false exactly when and have different truth values; this is precisely the exclusive-or, relationship.
Equivalence Proofs in Practice
We now work through several examples that demonstrate the method and, simultaneously, show how Python can serve as a rapid sanity check.
Show that .
Show that is a tautology.
The formula reduces to with no surviving variables, confirming it is a tautology regardless of assignment.
Show that .
Prove the above result.
This result captures a natural proof strategy: to show that a disjunction implies something, it suffices to show that each disjunct separately implies it.
Example 1.34 (Negation of an Implication).
The negation of “If I think, then I am” () is: by the definition of and De Morgan (Theorem 1.26 ). So the negation is “I think and I am not.”
Example 1.35 (XOR Distributivity).
Is distributive over and ?
The claim holds. Expanding both sides via the definition :
Left side:
Right side:
Both sides reduce to the same expression. However, fails.
A single counterexample suffices: set , , .
Using equivalence proofs (not truth tables), show that . This establishes the contrapositive equivalence from first principles.
Show, using an equivalence proof, that . Identify precisely where the “flip” from to the structure of the result occurs, and which axiom is responsible.
The negation of “Candidates must have a degree in mathematics or computer science” is not “Candidates must have a degree in mathematics and computer science.” Using the propositions = “The candidate has a degree in mathematics” and = “The candidate has a degree in computer science,” express the original statement formally as an implication and compute its negation. Identify the De Morgan’s Law involved.
Normal Forms
We Finish off this chapter with Normal forms.
The equivalence proofs developed demonstrate that any compound proposition can be transformed into an equivalent expression using only the core connectives , , and . But this raises a question: given two arbitrary propositions, how do we determine whether they are equivalent without the algebraic ingenuity required for an equivalence proof? (excluding truth tables of course).
A normal form solves this by being a fixed structural template for propositional formulas: If two propositions are equivalent, their normal forms will be identical (after simplification). This converts the semantic question “do these formulas always agree?” into the syntactic question “do these strings match?” But before defining the two principal normal forms, we need some terminology.
A literal is a propositional variable or its negation. If is a propositional variable, then both and are literals.
A clause is a disjunction or conjunction of literals. A disjunctive clause (or simply a clause in the context of CNF) is a disjunction of literals. A conjunctive clause (or term) is a conjunction of literals.
Disjunctive Normal Form
Definition 1.38 (Disjunctive Normal Form).
A propositional formula is in Disjunctive Normal Form (DNF) if it consists of a disjunction of one or more terms, where each term is a conjunction of literals. That is, DNF has the shape:
where each is a literal.
The structure is: OR of ANDs. Each conjunctive term describes one specific scenario under which the formula holds; the overall disjunction asserts that at least one of these scenarios is realised.
The following formulas are in DNF:
- . Two terms, each a conjunction of two literals.
- . A single literal is a degenerate term (a conjunction of one literal).
- .
The following formulas are not in DNF:
- . The negation is not a literal.
- .
- .
Constructing DNF from Truth Tables
Every compound proposition can be mechanically converted to DNF via its truth table via the procedure:
- Construct the truth table for the proposition.
- Identify every row where the proposition evaluates to .
- For each such row, form a conjunctive term: include the variable if it is assigned in that row, or if it is assigned .
- Take the disjunction of all such terms.
Each term encodes exactly one satisfying assignment, and the disjunction collects them all.
Find the DNF of .
We construct the truth table:
Rows 2, 4, 6, 7, 8 evaluate to . Reading off each row:
This is the full DNF. It can be simplified using the equivalence (which follows from Distributivity and Complement). Group the first two terms:
For the last three terms, observe that we may use Idempotence (Theorem 1.23 ) to duplicate the fifth term () without altering the formula. This allows two independent groupings:
Combining:
Applying the definition of and De Morgan (Theorem 1.26 ) in reverse: . The simplified DNF recovers the original formula, confirming equivalence.
Conjunctive Normal Form
Definition 1.41 (Conjunctive Normal Form).
A propositional formula is in Conjunctive Normal Form (CNF) if it consists of a conjunction of one or more clauses, where each clause is a disjunction of literals. That is, CNF has the shape:
where each is a literal.
The structure is: AND of ORs, the dual of DNF. Each disjunctive clause represents a constraint that must be satisfied; the conjunction demands that every constraint holds simultaneously.
The following formulas are in CNF:
- .
- .
The following formulas are not in CNF:
- .
- .
Constructing CNF
There are two systematic methods for obtaining CNF.
Method 1: Algebraic manipulation. Eliminate all implications using the defining equivalences of and . Push negations inward using De Morgan’s Laws (Theorem 1.26 ) and Double Negation (Theorem 1.22 ). Then distribute over using the equivalence (the disjunctive form of Distributivity) until every clause is a disjunction of literals.
Method 2: Truth table (via negation of DNF). Observe that by Double Negation (Theorem 1.22 ), any proposition satisfies . Construct the DNF of by reading off the rows where evaluates to (equivalently, where evaluates to ). Then negate the resulting DNF. By De Morgan’s Laws (Theorem 1.26 ), negating a disjunction of conjunctions produces a conjunction of disjunctions: precisely CNF.
Find the CNF of .
Method 1 (Algebraic):
Method 2 (Truth table):
The formula evaluates to in rows 5 and 7. Form the DNF of the negation by reading these rows: and simplify, thus giving . Now negate: by De Morgan (Theorem 1.26 ) and Double Negation (Theorem 1.22 ). This is already in CNF.
Remark.
Method 2 produced , while Method 1 produced . These are equivalent: the second clause in Method 1’s result is absorbed by the first via Absorption (Theorem 1.25 ), since any assignment satisfying automatically satisfies .
The Cost of Canonicality
Normal forms guarantee a canonical structure, but this guarantee comes at a price. Converting between normal forms can cause an exponential blowup in the number of clauses.
Consider a formula already in DNF with terms:
To convert this to CNF, we must distribute over repeatedly. Each application of Distributivity doubles the number of clauses. Starting with :
Two terms in DNF produce four clauses in CNF. Adjoining a third term via disjunction and distributing again doubles to eight clauses. After terms, the CNF may contain up to clauses. The symmetric explosion occurs when converting CNF to DNF.
This exponential blowup is an intrinsic property of the normal forms themselves. It is also the reason why the satisfiability of CNF formulas (the SAT problem) occupies a central position in complexity theory: determining whether a CNF formula has a satisfying assignment is the canonical NP-complete problem, meaning that no known algorithm solves it efficiently in all cases.
Find the DNF of using the truth table method. Simplify the result.
Convert into DNF using algebraic manipulation (Distributivity, not truth tables). Verify your result computationally.
Find the CNF of using both methods (algebraic and truth table). Confirm that both methods yield equivalent results.
Application: Knights and Knaves
Normal forms and propositional reasoning converge naturally in logic puzzles, where the challenge is to deduce facts from constrained declarations. Consider the following scenario.
On an island, every inhabitant is either a knight (who always tells the truth) or a knave (who always lies). You encounter two inhabitants, and .
- says: “B is a knight.”
- says: “The two of us are of opposite types.”
Let denote ” is a knight” and denote ” is a knight.” We translate the scenario into propositional logic.
- If is a knight ( is ): then ‘s statement is true, so is . If is a knave ( is ), then ‘s statement is false, so is . In both cases, ‘s declaration encodes .
- ’s statement asserts that and are of opposite types, which means exactly one of is : this is . If is a knight ( is ), then must be . If is a knave ( is ), then must be . So ‘s declaration encodes .
The full constraint is thus
-
Case 1: Assume is . From , we get is . Then . But . The conjunction evaluates to . Contradiction.
-
Case 2: Assume is . From , we get is . Then . And . The conjunction evaluates to .
Therefore both and are knaves.
On the same island, you meet three inhabitants , , and . says: “All of us are knaves.” says: “Exactly one of us is a knight.” Using propositional variables , , for , , respectively, determine the types of all three inhabitants. Verify your solution computationally.
Exercises
Answers are checked in your browser, as often as you like. Nothing is sent anywhere and
nothing is kept but your own work. A formula may be written with the symbols themselves or
with ~ & | -> <-> ^, and \and, \or, \to expand as you type.
For each implication below, which of the four statements is its converse?
If it is raining, then the ground is wet.
If is divisible by 4, then is even.
If a function is differentiable, then it is continuous.
Construct a compound proposition in , and that is true exactly when:
is true, is false and is false.
exactly one of , , is true.
at least two of , , are true.
The exclusive or does not distribute over conjunction: . Give an assignment at which the two sides differ.
Write each of the following with the connectives named and no others.
, in .
, in .
, in and .
Find the disjunctive normal form of , simplified as far as it will go.
Find the conjunctive normal form of , simplified as far as it will go.
The compound proposition involves four propositional variables. Settle it without constructing the sixteen-row truth table.
An assignment at which it is true.
An assignment at which it is false.
The proposition is therefore:
On an island, knights always tell the truth and knaves always lie. Person says: “If I am a knight, then is a knight.” Determine what and are.
Exercises in Lean
The proofs below are checked in your browser. Nothing is sent anywhere, and nothing is
stored but your own work. Type \to for →,
\and for ∧, \< and
\> for ⟨ ⟩.
Everything above this point was checked by hand. Lean is a language in which a statement and its proof are written so that a machine can check them instead, and it is what the rest of these notes will be verified in. This sheet is where we learn to write in it.
Each box below holds one statement. The grey lines are given and cannot be edited; the lines under them are ours to write, one tactic to a line. Underneath the box sits the info view, which shows what is left to prove and follows the cursor: put the caret between two lines of a proof and it reports the state at that point, which is the only way to see what a tactic has actually done.
Statements and proofs
p : Prop reads ” is a statement”, something that is either true or false. hp : p reads “hp is a proof of ”, and assuming amounts to the same thing, since a hypothesis is a proof we were handed rather than one we made.
A goal is shown as a list of hypotheses, a turnstile, and then the statement to be proved. What stands above the ⊢ we may use; what stands after it we must reach. A proof is finished when no goals are left.
Implication
Three tactics prove everything in this part.
intro
To prove we may assume and prove from it. So if the goal is ⊢ p → q, then intro hp takes that assumption, names it hp, and leaves the goal ⊢ q. Several may be taken at once: intro hp hq.
exact
If a hypothesis is exactly the statement we are trying to prove, exact hp closes the goal. Note that exact p does not: p is the statement and hp is a proof of it, and it is proofs that close goals.
Example.
Three assumptions, one of which is what we want.
apply
apply argues backwards. If the goal is and we hold h : p → q, then it is enough to prove , so apply h replaces the goal ⊢ q with ⊢ p. It works only when the conclusion of h is the goal.
Implications also apply forwards, and read left to right: with h : p → q and hp : p, the term h hp is a proof of . So exact h hp closes in one line what apply h and then exact hp closes in two.
Example.
The goal is an arrow, so we may assume its left side. What we assume is never used again.
Example.
Backwards, in two steps. Putting exact h hp in place of both lines does the same work forwards.
An arrow chain groups to the right: p → q → r is p → (q → r), so to reach we must supply both a and a . If h : p → q → r and the goal is ⊢ r, then apply h leaves two goals rather than one, and a tactic acts only on the first of them.
Every statement implies itself.
A statement that holds goes on holding under a further assumption.
From , together with , reach .
Implication is transitive.
If follows from and together, and follows from , then follows from alone.
True and False
True is Lean’s and False is its . Each is a statement like any other, and each has a tactic of its own.
trivial
trivial closes the goal ⊢ True, which asks for nothing.
Example.
The hypothesis plays no part. Nothing is needed to prove .
exfalso
Since implies everything, a proof of is a proof of anything, and exfalso replaces the goal, whatever it was, with ⊢ False. It is the move to make when the hypotheses already contradict each other, because the contradiction is then the whole of what remains.
Example.
Nothing is known about , and nothing needs to be.
The true statement holds.
Anything at all implies the true statement.
The true statement does not imply the false one.
And anything follows from the claim that it does.
From and a refutation of , any follows.
Negation
In Lean ¬p is not a connective of its own. It is defined to be p → False, so the two are one statement and either may be given where the other is asked for. A proof of ¬p is therefore a thing that turns a proof of into a contradiction: intro opens a goal ⊢ ¬p exactly as it opens an arrow, and if hnp : ¬p and hp : p then hnp hp is a proof of False.
Example.
The negation is applied to the proof it refutes.
by_contra
To prove by contradiction we assume and derive . Where the goal is ⊢ p, by_contra hp adds hp : ¬p and changes the goal to ⊢ False. This is the one classical step available here: it is the law of excluded middle in the form of a tactic, and the exercises that need it are the ones that cannot be done without it.
The two readings of are one statement.
The false statement can be refuted.
A statement implies its double negation.
An implication yields its contrapositive.
And the contrapositive yields the implication back.
What the checker understands
Tactics
| intro h | assume the hypothesis of an implication, naming it h |
| exact e | give the proof outright |
| apply f | reduce the goal to the hypotheses of f |
| assumption | close the goal with a hypothesis already present |
| trivial | close the goal True |
| exfalso | replace the goal with False |
| by_contra h | assume the negation of the goal |
Results you may cite
| Classical.em | ∀ (a : Prop), a ∨ ¬a — the law of excluded middle |
| Classical.byContradiction | ∀ {a : Prop}, (¬a → False) → a — proof by contradiction; the tactic by_contra does this for you |
| Classical.byCases | ∀ {a b : Prop}, (a → b) → (¬a → b) → b — split on whether a holds |
| not_not | ∀ {a : Prop}, ¬¬a ↔ a — double negation |
| not_and_or | ∀ {a b : Prop}, ¬(a ∧ b) ↔ ¬a ∨ ¬b — De Morgan |
| not_or | ∀ {a b : Prop}, ¬(a ∨ b) ↔ ¬a ∧ ¬b — De Morgan |
| not_imp | ∀ {a b : Prop}, ¬(a → b) ↔ a ∧ ¬b |
| and_comm | ∀ {a b : Prop}, a ∧ b ↔ b ∧ a |
| or_comm | ∀ {a b : Prop}, a ∨ b ↔ b ∨ a |
From the logical core
| And.intro | ∀ {a b : Prop}, a → b → a ∧ b |
| And.left | ∀ {a b : Prop}, a ∧ b → a |
| And.right | ∀ {a b : Prop}, a ∧ b → b |
| And.symm | ∀ {a b : Prop}, a ∧ b → b ∧ a |
| Or.inl | ∀ {a b : Prop}, a → a ∨ b |
| Or.inr | ∀ {a b : Prop}, b → a ∨ b |
| Or.elim | ∀ {a b c : Prop}, a ∨ b → (a → c) → (b → c) → c |
| Or.symm | ∀ {a b : Prop}, a ∨ b → b ∨ a |
| Iff.intro | ∀ {a b : Prop}, (a → b) → (b → a) → (a ↔ b) |
| Iff.mp | ∀ {a b : Prop}, (a ↔ b) → a → b |
| Iff.mpr | ∀ {a b : Prop}, (a ↔ b) → b → a |
| Iff.symm | ∀ {a b : Prop}, (a ↔ b) → (b ↔ a) |
| Iff.rfl | ∀ {a : Prop}, a ↔ a |
| Iff.trans | ∀ {a b c : Prop}, (a ↔ b) → (b ↔ c) → (a ↔ c) |
| True.intro | True |
| False.elim | ∀ {a : Prop}, False → a |
| absurd | ∀ {a b : Prop}, a → ¬a → b |
| id | ∀ {a : Prop}, a → a |
| mt | ∀ {a b : Prop}, (a → b) → ¬b → ¬a |
| Eq.refl | ∀ {α : Type} (a : α), a = a |
| Eq.symm | ∀ {α : Type} {a b : α}, a = b → b = a |
| Eq.trans | ∀ {α : Type} {a b c : α}, a = b → b = c → a = c |
| congrArg | ∀ {α : Type} {β : Type} {a b : α} (f : α → β), a = b → f a = f b |
| Exists.intro | ∀ {α : Type} {p : α → Prop} (w : α), p w → ∃ x : α, p x |
| Exists.elim | ∀ {α : Type} {p : α → Prop} {b : Prop}, (∃ x : α, p x) → (∀ y : α, p y → b) → b |