The words that build mathematical claims, "not", "and", "or", "if ... then", mean something slightly different in conversation every time they are used, and a proof cannot rest on a word whose meaning moves.
The previous lesson unpacked "the sum of two odd integers is even" into a claim with an "if ... then" inside it, and its proofs worked only because it was clear what that claim asserted. This lesson makes that clarity routine. It says which sentences can be true or false, fixes the meaning of each connective with a truth table, and spends a good part of its time on the conditional, the connective every theorem is written in. It then treats logic as algebra: which compound statements always say the same thing, which are true whatever their parts, and how to rewrite one into another by a small set of laws. It ends with two results about the connectives themselves: every truth table can be written with "not", "and" and "or" alone, and in fact with a single connective. It assumes school algebra and the definitions of even and odd: an integer is even when it equals for some integer , and odd when it equals .
Statements
A statement, or proposition, is a sentence that is either true or false. " is prime" is a statement, and a false one, since . "" is a true one, since . What matters is that the sentence has a truth value, not that anyone knows it. "Every even integer greater than is the sum of two primes" is Goldbach's conjecture, proposed in a letter to Euler in 1742 and checked by computer for every even number up to . Nobody knows whether it is true, but it is certainly one or the other, so it is a statement.
Plenty of mathematical sentences are not statements. "Is prime?" is a question and "Let " is an instruction. The subtler case is a sentence with a free variable, such as "", which is true when , false when , and has no truth value until is pinned down. Such a sentence is an open sentence. Turning open sentences into statements is the job of the next lesson; this one works with statements, or with open sentences read for one value of the variable at a time.
Statements are written with capital letters, , , , so that the structure of a claim can be seen apart from its content. The rules below depend only on whether each part is true or false, never on what it says. A statement with no connectives inside it, such as " is prime", is called atomic; one built from others with connectives is compound.
Is "this sentence is false" a statement?
No, and the reason matters. Suppose it were true. Then what it says holds, so it is false. Suppose it were false. Then what it says fails, so it is not false, that is, it is true. Either truth value leads to the other, so the sentence cannot consistently have one, and it fails the definition of a statement. This is the liar paradox, known since antiquity in the form of Epimenides the Cretan saying that all Cretans are liars.
The paradox is not a curiosity. It arises from a sentence that talks about its own truth, and the same pattern of self-reference drives some of the deepest results of modern logic. Bertrand Russell's paradox of 1901 considers the set of all sets that are not members of themselves and asks whether it is a member of itself; it has the liar's shape exactly, and it forced mathematicians to lay down axioms saying which sets exist, as the lesson on sets explains. Kurt Gödel's incompleteness theorem of 1931 builds a sentence of arithmetic that says, in effect, "this sentence cannot be proved". Unlike the liar, that sentence is a genuine statement: it cannot be false (if it were, it could be proved, and a proof of a false statement cannot exist in a sound system), so it is true and unprovable.
For this course the lesson is modest. The logic that follows assumes that every statement is exactly one of true and false, and the sentences it applies to are ordinary mathematical ones that talk about numbers, sets and functions, not about their own truth.
Not, and, or
Each connective is defined by saying, for every combination of truth values of its parts, whether the compound is true. With two parts there are four combinations, and a truth table lists them, one per row.
Negation, written and read "not ", is true exactly when is false. Conjunction, , read " and ", is true exactly when both parts are true. Disjunction, , read " or ", is true when at least one part is true, including when both are.
| T | T | F | T | T |
| T | F | F | F | T |
| F | T | T | F | T |
| F | F | T | F | F |
The last column is the one that departs from conversation. "Soup or salad" on a menu usually means one but not both. In mathematics "or" is always inclusive, and the sentences mathematicians write show why. The rule "if then or " must not exclude , and " is divisible by or by " is true of . When the exclusive sense is wanted it is spelt out: " or but not both", which is . This is the exclusive or, sometimes written , and it is true in the middle two rows only.
The negation of a statement is whatever is true in exactly the cases where the statement is false, and ordinary language often reaches for an opposite instead. The negation of "" is "", not "": at both "" and "" are false, so the second cannot be the negation of the first. And "" is itself a disjunction, " or ". Likewise the negation of " is even" is " is not even", which becomes " is odd" only once it is known that every integer is one or the other, a fact the lesson on direct proof proves.
English uses many words for . "But", "although", "whereas" and "yet" all mean "and" to a logician, whatever contrast they suggest: " is prime but is not" is . Mathematical writing also hides conjunctions in chains: "" is " and ", and "" is " and ".
Compound statements need brackets, just as in arithmetic, since could mean or , and these differ. The convention is that applies to the smallest thing after it, so means . For the other connectives this course uses brackets whenever there could be doubt.
The conditional
The fourth connective is the conditional, , read "if then " or " implies ". is the hypothesis (or antecedent) and the conclusion (or consequent).
| T | T | T |
| T | F | F |
| F | T | T |
| F | F | T |
The first two rows need no defence. "If is divisible by , then is even" is kept by a number divisible by that is even, and would be broken by one divisible by that is odd: a true hypothesis with a false conclusion is exactly what it means for an implication to fail.
The last two rows are the ones that surprise. Whenever the hypothesis is false, the conditional is true, whatever the conclusion, so "if , then is even" is a true statement. A conditional true because its hypothesis is false is called vacuously true. It looks like a convention, and slightly at odds with sense, but no other choice would let mathematics state its theorems, as the next section shows.
Vacuous truth turns up constantly in mathematics, usually without comment. "Every element of the empty set is even" is true, because it says "for every , if is in the empty set then is even", and the hypothesis is false for every . "All the prime factors of are greater than " is true for the same reason. A definition that says "a set of numbers is bounded below by if every element is at least " makes the empty set bounded below by , and by every other number too. These are not tricks; they are what the definitions say, and results about empty sets and edge cases come out right only because of them.
Why a false hypothesis gives a true conditional
Take a theorem nobody doubts: for every integer , if is divisible by , then is even. It claims something about every integer, so it is true only if each instance, one conditional per integer, is true. At the instance has a true hypothesis and a true conclusion. At the hypothesis is false and the conclusion true. At both are false. If either of the last two instances counted as false, this theorem would be false, and so would nearly every theorem of the form "if ... then", since nearly any hypothesis fails for some values. Those rows have to be true for mathematics to be sayable at all.
Nothing else could go in them either. Making both rows false turns into , so the theorem would assert that is divisible by . Making only the false-true row false turns it into the biconditional of the next section, so the theorem would claim every even number is divisible by , which refutes. Making only the false-false row false gives a column identical to , and the hypothesis would do nothing.
The conditional asserts no connection between its parts: "if , then is even" is true though its halves are unrelated. In mathematics that costs nothing, because the connection is what the proof supplies. The table also tells a proof where to look. A conditional can fail only in the row where is true, so to prove it is enough to assume and show that follows, which is what the previous lesson did when it began "let and be odd".
That same row gives the negation. Since is false only when is true and false, its negation is . The negation of an implication is not another implication: it says the hypothesis holds and the conclusion fails, which is what a counterexample exhibits.
Example. Negate "if is prime, then is odd", decide whether the conditional is true for , and , and say what this shows.
The negation is " is prime and is not odd", since is . For the hypothesis is true and the conclusion false, so the conditional is false, and its negation is true: is prime and not odd. For the hypothesis is false, since , so the conditional is vacuously true. For both parts are true and so is the conditional. The claim "every prime is odd" is therefore false, and is the counterexample: an integer at which the negation holds.
Now you. Negate "if , then ", and decide whether the conditional is true for , and .
Answer
The negation is " and ". At both and hold, so the conditional is true. At the hypothesis fails, so the conditional is vacuously true, even though . At the hypothesis and the conclusion both fail, and again the conditional is vacuously true. None of the three makes the negation true, and indeed nothing can: if then is positive and .
Isn't "if the Moon is made of cheese, then " nonsense rather than true?
In conversation, yes, because an English "if ... then" usually promises a connection: the conclusion is supposed to follow because of the hypothesis. The conditional of this lesson, often called the material conditional, promises only that the hypothesis is not true while the conclusion is false. It is the weakest statement that still does the one job theorems need, which is to rule out a true hypothesis with a false conclusion.
The debate is old. Logicians in ancient Greece argued over what makes a conditional true, and Philo of Megara, around 300 BCE, gave the answer used here: a conditional is false only when it leads from a truth to a falsehood. Others demanded a real connection, and philosophers still study "relevance logics" and theories of counterfactuals ("if the match had been struck, it would have lit") in which the connection matters. Mathematics chose Philo's version because it is the one that makes the rules of proof work: with it, and together always give , a conditional is equivalent to its contrapositive, and a universal "if ... then" theorem is true exactly when it has no counterexample.
People reason badly with conditionals even when the stakes are clear. In 1966 the psychologist Peter Wason showed subjects four cards, each with a letter on one side and a number on the other, showing E, K, 4 and 7, and asked which cards must be turned over to test the rule "if a card has a vowel on one side, then it has an even number on the other". Most people choose E, or E and 4. The right answer is E and 7. The rule can fail only on a card with a vowel and an odd number, so the E must be checked for an odd number and the 7 for a vowel; the 4 cannot break the rule whatever is on its back, since a conditional with a true conclusion is true. The truth table is not an arbitrary convention that conflicts with good sense. Used carefully, it is good sense.
The biconditional
The fifth connective is the biconditional, , read " if and only if " and often abbreviated " iff ". It is true when and have the same truth value, and false when they differ.
| T | T | T | T | T | T |
| T | F | F | T | F | F |
| F | T | T | F | F | F |
| F | F | T | T | T | T |
The fifth and sixth columns agree in every row, so a biconditional says exactly that each part implies the other. That is why proving an "if and only if" takes two proofs, one for each direction, and why the lesson on direct proof labels them and . The biconditional is also the negation of the exclusive or: is true where is false, and the reverse.
A true biconditional says that two conditions are interchangeable. "An integer is divisible by if and only if it is divisible by both and " means that, for each integer, the two sides are both true or both false, so one may be replaced by the other anywhere. Mathematicians spend a great deal of effort finding such equivalences, because each one gives two ways to think about the same thing.
The biconditional is not the same as equality of statements, but it behaves like it. For every , is true; if then ; and if and , then . The last fact justifies chains such as " if and only if if and only if or ", where each link is a separate equivalence and the chain concludes that the first and last are equivalent.
Tautologies, contradictions and valid arguments
A truth table can be built for any compound statement, one column per piece, working outwards from the atomic statements. With two atomic statements there are rows; with three there are ; with there are , since each atomic statement independently takes one of two values. By convention the rows are listed systematically: the first variable is T in the top half and F in the bottom half, the second alternates in blocks half as long, and so on down to the last, which alternates every row.
Some compound statements come out true in every row, whatever their parts say. Such a statement is a tautology. One that is false in every row is a contradiction, and one that is neither is contingent. Three tautologies are basic enough to have names.
- The law of excluded middle, : every statement is true or its negation is.
- The law of non-contradiction, : no statement is true together with its negation.
- The law of identity, .
Their tables have two rows each and are immediate. A tautology stays a tautology when its atomic statements are replaced by any statements at all, however complicated, since the table never looked at what they said. So is true for every , and so is .
One tautology explains a remark in the previous lesson, that a system of axioms must be free of contradictions. The statement is a tautology: its hypothesis is false in every row, so the conditional is vacuously true in every row, whatever is. So from a contradiction, every statement follows. This is the principle of explosion, and it means that a single contradiction among the axioms would make every statement a theorem, including every false one. The lesson on contrapositive and contradiction turns the same fact into a method: if an assumption leads to a contradiction, the assumption is false.
Tautologies of the form "if these premises, then this conclusion" are the valid patterns of reasoning. An argument with premises and conclusion is valid when is a tautology, which means: in no row are all the premises true and the conclusion false. Validity is about form, not truth. A valid argument with a false premise may have a false conclusion; what it cannot do is lead from true premises to a false conclusion. The patterns used most often in proofs are these.
- Modus ponens: from and , conclude . Every application of a theorem is one: the theorem is , and checking its hypothesis gives .
- Modus tollens: from and , conclude .
- Hypothetical syllogism: from and , conclude . This is how results chain together.
- Disjunctive syllogism: from and , conclude .
- Proof by cases: from , and , conclude .
Two invalid patterns are common enough to have names too. Affirming the consequent argues from and to : "if is divisible by then is even; is even; so is divisible by ", which fails at . Denying the antecedent argues from and to : "if is divisible by then is even; is not divisible by ; so is not even", which fails at too.
Example. Show that hypothetical syllogism is valid: is a tautology.
With three atomic statements there are eight rows. Write for the hypothesis .
| T | T | T | T | T | T | T | T |
| T | T | F | T | F | F | F | T |
| T | F | T | F | T | F | T | T |
| T | F | F | F | T | F | F | T |
| F | T | T | T | T | T | T | T |
| F | T | F | T | F | F | T | T |
| F | F | T | T | T | T | T | T |
| F | F | F | T | T | T | T | T |
The last column is T in every row, so the statement is a tautology.
There is a faster way, and it scales better. A conditional is false only when its hypothesis is true and its conclusion false, so look for such a row and see whether one can exist. For the conclusion to be false, must be T and must be F. For the hypothesis to be true, both and must be T. With true, forces true; with false, forces false. cannot be both, so no falsifying row exists, and the statement is a tautology. This is the same search as in the table, organised by working backwards from the one row that could do damage.
Now you. Show that modus tollens is valid, that is, is a tautology, and that affirming the consequent is not, by finding a row in which is false. Give an instance of the second with real numbers.
Answer
Modus tollens. For the conditional to be false, its conclusion must be F, so is T, and its hypothesis must be T, so is T and is T, which makes false. But then has a true hypothesis and a false conclusion, so it is F, not T. No row makes the whole statement false, so it is a tautology.
Affirming the consequent. Take false and true. Then is T (vacuously) and is T, so the hypothesis is T, while the conclusion is F. In that row the conditional is false, so it is not a tautology, and the argument pattern is invalid.
An instance. "If then . We have . So ." The premises are true for , since the conditional holds for every real number and , but the conclusion is false. That is the row false, true.
Is there a faster way than writing out all rows?
Sometimes, as the backwards search in the Example shows. But in general nobody knows one, and this is one of the great open problems of mathematics and computer science.
The question "is there a row that makes this compound statement true?" is called the Boolean satisfiability problem, or SAT. A statement is a tautology exactly when its negation has no satisfying row, so deciding tautologies and solving SAT are the same problem in two guises. The truth table settles it, but with atomic statements it has rows: statements give over a billion rows, and give more rows than there are atoms in the observable universe. Checking a proposed row, on the other hand, is quick. The question is whether finding a row can always be made nearly as quick as checking one.
In 1971 Stephen Cook proved that SAT is as hard as any problem whose solutions can be checked quickly: a fast method for SAT would give a fast method for all of them, including scheduling, route planning and breaking many codes. Whether such a method exists is the P versus NP problem, one of the seven Millennium Prize Problems announced by the Clay Mathematics Institute in 2000, with a prize of a million dollars. Most experts believe no such method exists.
In practice, modern SAT solvers use clever searches to handle statements with millions of atomic parts, provided they have useful structure, and they have been used to prove theorems. In 2016 Marijn Heule, Oliver Kullmann and Victor Marek used one to settle the Boolean Pythagorean triples problem, showing that the numbers to cannot be split into two groups neither of which contains a Pythagorean triple , while to can. The proof the computer produced was about terabytes long: a truth table argument on an industrial scale.
Logical equivalence and its laws
Two compound statements are logically equivalent when they have the same truth value in every row of their truth table. Equivalently, and are equivalent when is a tautology. Since the table lists every case, checking the rows is a complete proof. Equivalent statements say the same thing in different words, and a proof may replace either by the other at any point. Note that , which denies the whole conjunction, is a different thing from , where applies only to .
The most useful equivalences say how to negate an "and" or an "or". To deny that two things both hold is to say that at least one fails, and to deny that at least one holds is to say that both fail. These are De Morgan's laws, after Augustus De Morgan, who stated them in 1847, and they are what a proof needs whenever it must say what the failure of a condition looks like.
Example. Show that and are equivalent, and use this to negate " and ".
Compute both columns in each of the four rows.
| T | T | T | F | F | F | F |
| T | F | F | T | F | T | T |
| F | T | F | T | T | F | T |
| F | F | F | T | T | T | T |
The fourth and seventh columns agree in every row, so the two statements are equivalent. Now let be "" and be "". The negation of is , and the negations of the parts are "" and "". So the negation of " and " is " or ".
Now you. Show that and are equivalent, and use this to negate " or ".
Answer
is false only in the row where and are both false, so is true in that row and false in the other three. is true only when and are both true, which is the same row. The columns agree in all four rows, so the statements are equivalent. The negation of " or " is therefore " and ", that is, .
The common error is to negate the parts and leave the connective alone. "Not ( and )" is not " and ", which no number satisfies. Negating a compound always turns "and" into "or" or the reverse.
De Morgan's laws are two entries in a short list of standard equivalences, each checked by a truth table of at most eight rows. In the list, stands for any tautology and for any contradiction.
| Name | Statement | Equivalent to |
|---|---|---|
| Double negation | ||
| Commutative laws | and | and |
| Associative laws | and | and |
| Distributive laws | ||
| De Morgan's laws | and | and |
| Idempotent laws | and | |
| Absorption laws | and | |
| Identity laws | and | |
| Domination laws | and | and |
| Complement laws | and | and |
| Material implication | ||
| Contrapositive | ||
| Biconditional |
Two of these deserve comment. Material implication says that "if then " is the same as "not , or ": the conditional is false only when is true and false, which is exactly when is false. It is the bridge that lets conditionals be handled with the laws for , and . The distributive laws come in two forms, and the second, with distributing over , has no counterpart in arithmetic, where is not . Logic is more symmetric than arithmetic: every law in the list stays a law when and are exchanged and and are exchanged, a fact called duality.
The laws turn logic into algebra. Because the truth value of a compound depends only on the truth values of its parts, replacing any part by an equivalent part gives an equivalent whole. So an equivalence can be proved by a chain of rewritings, each justified by a law, in place of a truth table. For three or four atomic statements the chain is usually shorter than the table, and it often shows why the equivalence holds. It gives, for instance, a two-line derivation of the negation of a conditional: is equivalent to by material implication, which is equivalent to by De Morgan, and so to by double negation.
Example. Prove, using the laws, that is equivalent to , and say what the equivalence means for proofs.
| Step | Statement | Reason |
|---|---|---|
| 1 | given | |
| 2 | material implication, twice | |
| 3 | distributive law, read from right to left | |
| 4 | material implication |
Each line is equivalent to the one before, so the first is equivalent to the last. For proofs, it says that to prove "if then both and " it is enough to prove "if then " and "if then " separately, and conversely. The proof that gives both and in the lesson on direct proof is of this shape.
Now you. Prove, using the laws, that is equivalent to , and say what it means for proofs.
Answer
| Step | Statement | Reason |
|---|---|---|
| 1 | given | |
| 2 | material implication, twice | |
| 3 | commutative law, twice | |
| 4 | distributive law, read from right to left | |
| 5 | De Morgan's law | |
| 6 | commutative law | |
| 7 | material implication |
For proofs, it is the justification of proof by cases: to show that follows from " or ", show that it follows from and that it follows from . Compare the Example: a conjunction in the conclusion splits into two conditionals joined by "and", and so does a disjunction in the hypothesis. A conjunction in the hypothesis behaves differently: is equivalent to , which is weaker than either conditional alone.
Why do the laws of logic look so much like the laws of algebra?
Because they are the laws of an algebra, and the first person to see this was George Boole. In The Mathematical Analysis of Logic (1847) and The Laws of Thought (1854), Boole wrote statements as letters, "and" as multiplication and "not " as , with for true and for false. In his system for every , since " and " says no more than , and this equation, which holds for the numbers and and no others, singles out the two truth values. The algebra now called Boolean algebra grew from his work.
The same algebra appears in two other places in this course and beyond. Replace statements by sets, "and" by intersection, "or" by union and "not" by complement, and every law in the table becomes a law of sets: De Morgan's laws for sets, the distributive laws, absorption, all of them. The reason is that " belongs to " means " belongs to and belongs to ", so each law of sets is a law of logic applied to membership. The lesson on sets proves them this way.
The second place is electronics. In his 1937 master's thesis at MIT, Claude Shannon showed that circuits of switches obey Boolean algebra: two switches in series pass current exactly when both are closed, which is "and", and two in parallel pass it when at least one is closed, which is "or". So designing a circuit is writing a compound statement, and simplifying the circuit is simplifying the statement by the laws. Every digital computer is built on this correspondence, and the section on functional completeness below explains why engineers can build all of it from one kind of component.
Converse, inverse and contrapositive
Swapping and negating the parts of gives three new conditionals: the converse , the inverse , and the contrapositive . Their tables settle which say the same thing as the original.
| T | T | T | T | T | T |
| T | F | F | F | T | T |
| F | T | T | T | F | F |
| F | F | T | T | T | T |
The contrapositive agrees with the original in every row, so the two are equivalent. The converse and inverse agree with each other (the inverse is the contrapositive of the converse) and differ from the original in the middle two rows. So a proof of is a proof of , which the lesson on contrapositive and contradiction turns into a method, while a proof of says nothing about . Treating it as if it did is the commonest logical error in student proofs.
The equivalence with the contrapositive also follows from the laws, without a table: is equivalent to by material implication, to by commutativity, to by double negation, and so to by material implication again.
Example. Write the converse, inverse and contrapositive of "if is divisible by , then is divisible by ", and decide which are true for every integer .
The statement is true: if for an integer , then , and is an integer. The converse is "if is divisible by , then is divisible by ", which is false, since is divisible by and not by . The inverse is "if is not divisible by , then is not divisible by ", and refutes it too, as it must, being equivalent to the converse. The contrapositive is "if is not divisible by , then is not divisible by ", which is true because it is equivalent to the original.
Now you. For real numbers , write the converse, inverse and contrapositive of "if , then ", and decide which are true.
Answer
The statement is true: if then is positive, so . The converse, "if then ", is false, since gives with . The inverse, "if then ", is false by the same . The contrapositive, "if then ", is true, being equivalent to the original.
A conditional and its converse are independent: all four combinations of truth values occur. Both can be true ("if is even then is odd" and its converse), the statement can be true and its converse false (the Example), the reverse can happen (swap the parts of the Example), and both can be false ("if is prime then is odd", refuted by , and its converse, refuted by ). When both are true, the statement and its converse together make a biconditional.
Necessary, sufficient, only if, unless
When holds, is a sufficient condition for : having guarantees . And is a necessary condition for : without there is no , which is the contrapositive read aloud. Divisibility by is sufficient for divisibility by , and divisibility by is necessary for divisibility by . These are one fact seen from its two ends. A condition that is necessary and sufficient for is one equivalent to it: "a necessary and sufficient condition for to be divisible by is that it be divisible by and by ."
" only if " also means . "Only" marks the necessary condition, which is the conclusion: " is divisible by only if is even" says divisibility by cannot happen without evenness. By contrast " if " means . The two are opposite, so together they make "if and only if": is the same as , a condition both necessary and sufficient. That is why proving an "if and only if" takes two proofs, one per direction.
" unless " means that if fails, then holds: , which by material implication and double negation is . So "unless" is, for a logician, just "or". "The equation has a real solution unless its discriminant is negative" says: if the discriminant is not negative, there is a real solution. It makes no claim about what happens when the discriminant is negative; in conversation "unless" often suggests the converse too, and in mathematics it does not.
Several other phrases are common, and each has a fixed translation.
| English | Symbols |
|---|---|
| implies ; if then ; if ; whenever | |
| only if ; is sufficient for ; is necessary for | |
| provided that ; follows from | |
| unless | , that is, |
| if and only if ; is necessary and sufficient for ; exactly when | |
| neither nor |
One convention catches every newcomer. Definitions are written with "if", as in "an integer is even if for some integer ", but a definition is always read as "if and only if". The previous lesson used its definitions in both directions, producing a from an even number and concluding evenness from a , and was right to. Theorems get no such licence: in a theorem, "if" means only "if".
Normal forms
Every compound statement, however tangled, can be rewritten in one of two standard shapes, and the rewriting can be read straight off the truth table.
A literal is an atomic statement or the negation of one, such as or . A statement is in disjunctive normal form (DNF) if it is a disjunction of terms, each of which is a conjunction of literals, as in . It is in conjunctive normal form (CNF) if it is a conjunction of clauses, each of which is a disjunction of literals, as in . The names say which connective is on the outside: DNF is an "or" of "and"s, CNF an "and" of "or"s. A single literal, or a single term, counts as a (short) disjunction or conjunction.
The key observation is that each row of a truth table can be described by a conjunction of literals that is true in that row and in no other. For the row in which is T, is F and is T, the conjunction is : it is true exactly when is true, is false and is true. Now take any truth table. Write down the conjunction for each row in which the statement is T, and join them with . The result is true in a row exactly when one of its terms is true there, which happens exactly when that row is one of the T rows. So it has the given truth table, and it is in disjunctive normal form.
Conjunctive normal form comes from the F rows in the same way. For each row in which the statement is F, write the disjunction of literals that is false in that row and in no other: for the row T, F, T it is , which fails only when every literal fails. Join these clauses with . The result is false in a row exactly when one of its clauses is false there, that is, exactly in the F rows.
Example. The majority statement of , and is true exactly when at least two of the three are true. Find a DNF and a CNF for , and simplify them.
| row conjunction | row disjunction | ||||
|---|---|---|---|---|---|
| T | T | T | T | ||
| T | T | F | T | ||
| T | F | T | T | ||
| T | F | F | F | ||
| F | T | T | T | ||
| F | T | F | F | ||
| F | F | T | F | ||
| F | F | F | F |
The DNF is the disjunction of the four row conjunctions of the T rows:
and the CNF is the conjunction of the four row disjunctions of the F rows:
Both are correct and both are clumsy. The laws shorten them. The first two terms of the DNF share , and by the distributive law their disjunction is , which is by the complement and identity laws. More directly, is true exactly when some two of the three are true, which is exactly when at least two are true, so it is a shorter DNF for . The same reasoning applied to the CNF gives : this is true exactly when every pair contains a true statement, that is, when at most one of the three is false. The two short forms are duals of each other, as the duality principle predicts.
Now you. Find a CNF and a DNF for from its truth table, and check them against a short form obtained with the laws.
Answer
The statement is false exactly when is true and is false. With false, is true in the rows $(P, Q) = $ (T, T), (F, T) and (F, F). So the F rows are TTF, FTF and FFF, and the other five rows are T.
The CNF, one clause per F row, is
The DNF, one term per T row (TTT, TFT, TFF, FTT, FFT), is
With the laws: is equivalent to by material implication, and is equivalent to , so the statement is equivalent to . That is a DNF with two terms. It is true when is true (four rows) or when is T, is F and is F (one more row), five rows in all, matching the table. Distributing gives the CNF , which is false exactly when is false and either is false or is true, which are the three F rows found above.
Normal forms give every statement a standard shape. Two statements in the same atomic statements are equivalent exactly when their full DNFs (one term per T row) have the same terms, and SAT solvers take their input in CNF. The Logic course's lesson on normal forms treats them from a logician's side. The construction also proves something stronger, which is the subject of the next section.
Functional completeness
A truth function of variables is any rule that assigns T or F to each of the rows of a truth table. Each connective is one: is the truth function of two variables with a T in the first row only. Since each of the rows may independently get T or F, there are truth functions of variables. For two variables that is , and the five connectives of this lesson are just the most useful of the sixteen. The question is whether they, or fewer, are enough to express the others. A set of connectives is functionally complete if every truth function, of any number of variables, is the truth table of some statement built from atomic statements using only those connectives.
Theorem. The set is functionally complete.
Proof. Let a truth function of variables be given. If it is F in every row, it is the truth table of , which uses only and . Otherwise it has at least one T row, and the construction of the previous section produces a statement in disjunctive normal form, built from , and alone, that is true in exactly the T rows. Its truth table is therefore the given one.
Fewer connectives suffice. By De Morgan's law and double negation, is equivalent to , so every in a statement can be replaced by and without changing its truth table.
Corollary. The sets , and are functionally complete.
Proof. The first was just shown. For the second, is equivalent to , so can be removed in favour of and . For the third, is equivalent to by material implication (and double negation), so can be removed from in favour of and . In each case every statement in the complete set can be rewritten, one connective at a time, into an equivalent statement using only the smaller set.
Remarkably, a single connective is enough. The NAND ("not and") connective, , is defined to be equivalent to : it is false only when both parts are true.
Theorem. The set is functionally complete.
Proof. Since is complete, it is enough to express and using alone. First, is equivalent to , which is by the idempotent law. Second, is equivalent to , which is , and by the first part that is . So every statement built with and can be rewritten with alone.
Henry Sheffer published this in 1913, and NAND is often called the Sheffer stroke; Charles Sanders Peirce had noticed it around 1880 but did not publish. The same is true of NOR, , equivalent to , which Problem 11 asks you to prove.
Not every set of connectives is complete, and proving that one is not needs a different kind of argument: some property that all the statements built from the set share, and some truth function that lacks it.
Theorem. The set is not functionally complete. In particular, cannot be expressed using and alone.
Proof. Consider the row in which every atomic statement is true. Every atomic statement is true in that row. If two statements and are both true in that row, then so are and . Every statement built from atomic statements with and is made by finitely many such steps, starting from atomic statements, and each step keeps the property, so every such statement is true in the all-true row. But is false in the row where is true. So no statement built with and has the truth table of .
The argument, "the building blocks have the property, and each way of combining them preserves it", is an instance of structural induction, which the lesson on induction makes precise. It proves more than the theorem states: adding and to the set does not help, since and are also true whenever and are. Every complete set must contain some connective that can turn truth into falsehood.
Why does it matter that one connective is enough?
Because computers are built from it. A logic gate is a small circuit whose output voltage, high or low, is a truth function of its input voltages. In the transistor technology used in almost every chip since the 1980s, NAND and NOR gates are the simplest gates to build, each needing four transistors, while an AND gate is typically built as a NAND followed by a NOT. Functional completeness guarantees that any circuit, from an adder to a whole processor, can be built from NAND gates alone. Chip designers do not literally do that, but the standard libraries of components they work from are built around NAND and NOR, and the "NAND flash" memory in phones and memory sticks takes its name from the way its cells are wired, in series, like the transistors in a NAND gate.
An early example of single-gate design flew to the Moon. The Apollo Guidance Computer, which navigated the Apollo spacecraft, was built from integrated circuits that each contained NOR gates and nothing else. Using one type of chip simplified manufacturing and testing at a time when integrated circuits were new and unreliable, and functional completeness made it possible.
The counting fact also has a consequence. The number of truth functions grows so fast that most of them need enormous statements: in 1949 Claude Shannon showed, by counting, that for large almost every truth function of variables needs a circuit of size exponential in . Yet nobody can point to a specific, explicitly described truth function and prove that it needs a large circuit. That gap is closely tied to the P versus NP problem from the section on tautologies.
What connectives cannot say
The five connectives are now fixed, the negation of each compound can be written down mechanically, and every truth table can be expressed with them. Yet the argument for the conditional's table used something no connective contains. "For every integer , if is divisible by , then is even" is not a conditional between two statements, since " is divisible by " is an open sentence; the phrase "for every integer " is what made the whole a true statement. Refuting "every prime is odd" needed the opposite phrase: there is a prime that is not odd. Nearly every theorem is about all numbers or some number, and neither "all" nor "some" can be built from the five connectives. The next lesson adds them, with rules for negating them that turn "not every" into "some fails".
Problems
Work each problem on paper before opening anything; for Core and Challenge problems, try the hint before the solution.
Warm-up
1. Which of these are statements? For each statement, give its truth value. (a) is a factor of . (b) . (c) Factorise . (d) Every prime greater than is odd. (e) is prime.
Solution
(a) A statement, and true: .
(b) Not a statement: it is an open sentence with the free variable . It becomes a statement once is fixed, or once a quantifier is added, as in "for every real number , ", which is true.
(c) Not a statement: it is an instruction.
(d) A statement, and true. (A prime is not divisible by , since its only positive divisors are and ; that it is then odd uses the fact, proved in the lesson on direct proof, that every integer is even or odd.)
(e) A statement, and false. Since has the odd divisor , Problem 13 of the previous lesson shows that is composite: it is divisible by . Whether or not one knows the answer, the sentence has a truth value, which is what makes it a statement.
2. Write out the truth tables of and of , and decide whether they are equivalent. Then show the same thing using the laws.
Solution
| T | T | F | T | T | T |
| T | F | F | F | F | F |
| F | T | T | F | T | T |
| F | F | T | F | T | T |
The last two columns agree in every row, so the statements are equivalent.
With the laws: by the distributive law, is equivalent to . The first part is a tautology by the complement law (and commutativity), so by the identity law the whole is equivalent to , which is by material implication.
3. A triangle is isosceles if at least two of its sides are equal, and equilateral if all three are. For the statement "if a triangle is equilateral, then it is isosceles", write the converse, the inverse, the contrapositive and the negation, and say which are true for every triangle.
Solution
The statement is true: if all three sides are equal, then in particular two are.
The converse, "if a triangle is isosceles, then it is equilateral", is false: a triangle with sides , and is isosceles and not equilateral (these lengths do form a triangle, since ).
The inverse, "if a triangle is not equilateral, then it is not isosceles", is false, by the same triangle. It is equivalent to the converse.
The contrapositive, "if a triangle is not isosceles, then it is not equilateral", is true, being equivalent to the statement.
The negation of a statement about every triangle is, for a particular triangle, "the triangle is equilateral and not isosceles". No triangle satisfies it, as it must be, since the statement is true for every triangle.
4. Let be " is prime", be " is odd" and be "", for a positive integer . Translate each sentence into symbols. (a) is prime only if is odd. (b) is sufficient for to be odd. (c) Being odd is necessary for to be prime, provided . (d) is not prime unless it is odd. (e) is odd if it is prime and greater than .
Solution
(a) . "Only if" introduces the necessary condition, which is the conclusion. It is false for .
(b) . False for .
(c) . "Being odd is necessary for being prime" is , and the proviso makes it conditional on . It is true for every positive integer .
(d) " unless " is . Here is and is , so the translation is , the contrapositive of (a) and equivalent to it.
(e) . It is equivalent to (c): by the laws, is , and so is , since is .
Core
5. Prove the distributive law " is equivalent to " by a truth table. Then deduce the other distributive law, " is equivalent to ", without a table.
Hint
For the second part, apply the first law to the statements , and , and negate both sides.
Solution
| T | T | T | T | T | T | T | T |
| T | T | F | T | T | T | F | T |
| T | F | T | T | T | F | T | T |
| T | F | F | F | F | F | F | F |
| F | T | T | T | F | F | F | F |
| F | T | F | T | F | F | F | F |
| F | F | T | T | F | F | F | F |
| F | F | F | F | F | F | F | F |
The fifth and eighth columns agree in all eight rows, which proves the first law.
For the second, a tautology remains one when its atomic statements are replaced by any statements, so the first law holds with , , in place of , , : the statement is equivalent to . Equivalent statements have equivalent negations, so
Apply De Morgan's laws and double negation to each side. The left side becomes , then , then . The right side becomes , then . So is equivalent to .
The same argument proves the duality principle in general: negating both sides of any law and pushing the negations inwards exchanges with .
6. Prove or disprove each claim. (a) is equivalent to . (b) is equivalent to . (c) is a tautology. (d) is equivalent to .
Hint
Exactly one is false. For it, look for a row with false. For (d), find a simple description of the rows in which each side is true.
Solution
(a) False. Take false and false, with either value. Then is true (vacuously), so has a true hypothesis and a false conclusion, and is false. But has a false hypothesis, so it is true. The two differ in this row, so they are not equivalent. The conditional is not associative, which is why brackets around it are never omitted.
(b) True. By material implication twice, is equivalent to , which by associativity is . By De Morgan's law this is , and by material implication that is . In words: "if , then if then " says the same as "if and , then ". This is why a theorem with two hypotheses can be proved by assuming both at once.
(c) True. By material implication, the statement is equivalent to , which by the commutative and associative laws is . Each bracket is a tautology, so the whole is. It sounds absurd ("for any two statements, one implies the other"), and it is a reminder that the material conditional asserts no connection: if is true then holds, and if is false then holds.
(d) True. A biconditional is true exactly when and are both true or both false. Claim: is true exactly when an odd number of , , are true. Check by cases on . If is true, the whole is true exactly when is true, that is, when and are both true or both false, that is, when an even number of , are true, which together with the true makes an odd number in all. If is false, the whole is true exactly when is false, that is, when exactly one of , is true, again an odd number in all. The same argument, splitting on in place of , shows that is true exactly when an odd number of the three are true. The two descriptions coincide, so the statements are equivalent.
7. Find the flaw. A student writes: "To negate a conditional, negate both of its parts. So the negation of is , and the negation of 'if is divisible by , then is even' is 'if is not divisible by , then is not even'."
Hint
A statement and its negation must have opposite truth values in every row. Check the row with false and false.
Solution
In the row where and are both false, is true (vacuously), and is true too, since both its parts are true. A statement and its negation cannot both be true, so is not the negation of . What the student wrote is the inverse, which is equivalent to the converse and has nothing to do with the negation.
The correct negation is : the hypothesis holds and the conclusion fails. For the example, the negation of "if is divisible by , then is even" is " is divisible by and is not even", which no integer satisfies, as it should, since the original holds for every integer. The student's version is false for , which is not divisible by and is even.
The underlying error is treating as if it distributed over connectives. It does not distribute over or either (De Morgan's laws say what happens instead), and over it produces a conjunction.
8. On an island, every inhabitant is either a knight, who always tells the truth, or a knave, who always lies. (a) Inhabitant A says: "At least one of us two is a knave." What are A and B? (b) On another occasion, C says "D is a knight", and D says "C and I are of opposite types". What are C and D? In each part, write the information as statements with connectives and solve.
Hint
Let be the statement "A is a knight". Whatever A says is true exactly when A is a knight, so if A says , then holds.
Solution
Write for "A is a knight", and similarly for the others. A knave is then someone for whom the statement is false. If a person X says , then is true exactly when X is a knight, so holds.
(a) A says , so holds. If were false, the right side would have to be false too, so would be false; but is true, so it is true. That is impossible, so is true. Then the right side is true: holds, and since is false, is true. So A is a knight and B is a knave. Check: A, a knight, says truly that at least one of them (B) is a knave.
(b) C says , so . D says that exactly one of C and D is a knight, which is , so . From the first, and have the same truth value, so is false. Then the second says , so is false, and by the first is false. Both are knaves. Check: C, a knave, says falsely that D is a knight; D, a knave, says falsely that they are of opposite types.
Puzzles of this kind were popularised by Raymond Smullyan in the 1970s. Each is a small satisfiability problem: find the rows in which all the biconditionals are true.
9. Using the laws of the section on logical equivalence, and no truth tables, prove: (a) is equivalent to ; (b) is equivalent to ; (c) is a tautology.
Hint
In (a), push the negation inwards with De Morgan's laws first, then distribute. In (c), remove the arrows with material implication and regroup.
Solution
(a) By De Morgan's law, is equivalent to . By De Morgan's law and double negation, is equivalent to , so the whole is . By the distributive law this is . The first part is a contradiction by the complement law (with commutativity), so by the identity law ( is , after commuting) the whole is equivalent to .
(b) By the distributive law, is equivalent to . By the complement law is a tautology, and by the identity law is .
(c) By material implication twice, is equivalent to . By the commutative and associative laws this is . The bracket is a tautology by the complement law, and by the domination law is a tautology. So the statement is equivalent to a tautology, and is one. In words: if is true, then it follows from anything.
10. Let be the statement "exactly one of , , is true". Write in disjunctive normal form. Then prove that
is a conjunctive normal form for , that is, that it has the same truth table.
Hint
For the CNF, read each clause in words. The first says something about "at least", and each of the other three forbids something.
Solution
DNF. is true in exactly three rows: TFF, FTF and FFT. One term per row gives
CNF. Call the displayed statement . Its first clause, , is true exactly when at least one of the three is true. The clause is equivalent to by De Morgan's law, so it is true exactly when and are not both true; likewise the other two clauses say that and are not both true, and that and are not both true. So the last three clauses together are true exactly when no two of the three are true, that is, when at most one is true. Hence is true exactly when at least one and at most one is true, which is exactly when is true. The two have the same truth table.
This CNF is shorter than the one read off the five F rows, and it is the standard way to say "exactly one" to a SAT solver: one clause for "at least one", and one clause for each pair to say "not both".
11. The NOR connective is defined to be equivalent to . Prove that is functionally complete, and write and using alone.
Hint
Since is complete, it is enough to express and . Compare with the proof for NAND.
Solution
First, is equivalent to , which is by the idempotent law. Second, is equivalent to by double negation, which is , and by the first part that is . So and can both be expressed with alone. Since is functionally complete (the corollary in the section on functional completeness), every truth function can be expressed by first writing it with and and then replacing each occurrence of these by its expression in . Hence is functionally complete.
For : by De Morgan's law and double negation, is equivalent to , which is , that is, .
For : is equivalent to , which by the second part is , that is,
A check in one row: with true and false, is F, then is T, and is F, matching in that row.
12. Prove that is not functionally complete, but that is, where is a constant statement that is false in every row.
Hint
For the first part, adapt the proof that is not complete. For the second, express .
Solution
Not complete. Consider the row in which every atomic statement is true. Atomic statements are true in that row, and if and are true in that row, then so is , since its conclusion is true. Every statement built from atomic statements with alone is made by finitely many such steps, each of which keeps the property, so every such statement is true in the all-true row. But is false in any row where is true. So cannot be expressed with alone, and is not functionally complete.
Complete with . The statement is true exactly when is false, since its conclusion is always false; so it is equivalent to . Thus both and can be expressed with , and since is functionally complete (the corollary in the section on functional completeness), so is .
Adding breaks the argument of the first part exactly where it must: is not true in the all-true row. Reading as "not " is the idea behind proof by contradiction: to show , show that leads to something false.
Challenge
13. A binary connective is Sheffer if is functionally complete by itself. Prove that NAND and NOR are the only Sheffer connectives among the sixteen binary connectives.
Hint
First show that a Sheffer connective must make false and true, using the argument of Problem 12 and its mirror image with the all-false row. That leaves four candidates. Two are NAND and NOR. For the other two, show that every statement built with them is equivalent to an atomic statement or its negation.
Solution
Let be a Sheffer connective.
Step 1: is F. Suppose instead that is T. Then, as in Problem 12, every statement built with alone is true in the row where all atomic statements are true: atomic statements are, and if and are true in that row then so is . So could not be expressed, contradicting completeness.
Step 2: is T. Suppose instead that is F. Then in the row where all atomic statements are false, every statement built with is false, by the same argument. But is true in that row, so it could not be expressed, again contradicting completeness.
Step 3: the four candidates. With false and true, the connective is fixed by its values in the two middle rows, and .
- Both T: the table is F, T, T, T, which is NAND.
- Both F: the table is F, F, F, T, which is NOR.
- is T and is F: the table is F, T, F, T, which is the table of . So is equivalent to .
- is F and is T: the table is F, F, T, T, so is equivalent to .
Step 4: the last two are not Sheffer. Take the third, where is equivalent to . Claim: every statement built from atomic statements with alone is equivalent to or to for a single atomic statement . Atomic statements have this form. If and have it, say is equivalent to or , then is equivalent to , which is equivalent to or to (by double negation), so it has the form too. Every statement is built by finitely many such steps, so every one has the form. But is not equivalent to any of , , , : it differs from when is T and is F, from and from when both are T, and from when is F and is T. (A statement involving some other atomic statement has a truth value that changes with , so it cannot have the table of either.) So cannot be expressed, and this connective is not Sheffer. The fourth candidate is the same with the roles of and exchanged.
Conclusion. A Sheffer connective must be NAND or NOR, and both are Sheffer, by the theorem in the lesson and Problem 11.
14. Prove that no statement built from and using only and is equivalent to . Deduce that is not functionally complete.
Hint
Count the T's in the four-row truth table. Show that every statement built from and with and has an even number of them.
Solution
For a statement built from and , let be the number of rows, out of the four, in which is true. Claim: is even for every statement built from and with and .
Atomic statements. is true in two rows and so is , so .
Negation. is true exactly in the rows where is false, so , which is even if is.
Biconditional. Let and be statements with and even, and let be the number of rows in which both are true. The rows in which is true or is true number (the rows where both are true would otherwise be counted twice), so the rows in which both are false number . Now is true exactly in the rows where both are true or both are false, so
which is even, since and are even.
Every statement built from and with and is made from and by finitely many such steps, each of which keeps the number of T rows even, so every such statement has even. But is true in exactly one row, and is odd. So no such statement is equivalent to .
Hence the truth function of cannot be expressed with and , and is not functionally complete. The same count shows that and , each true in three rows, cannot be expressed either. The set can express exactly the eight truth functions of and with , or true rows; they are the truth functions that computer scientists call linear, and in Boole's algebra with for T they are the sums of , and with arithmetic done modulo .