Sign in

Libre University uses your GitHub account. Signing in is only needed to sit a final test, so the score is kept on your profile.

Statements and connectives

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 2k for some integer k, and odd when it equals 2k+1.

Statements

A statement, or proposition, is a sentence that is either true or false. "91 is prime" is a statement, and a false one, since 91=7×13. "210>1000" is a true one, since 210=1024. What matters is that the sentence has a truth value, not that anyone knows it. "Every even integer greater than 2 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 4×1018. 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 91 prime?" is a question and "Let n=91" is an instruction. The subtler case is a sentence with a free variable, such as "x>3", which is true when x=5, false when x=1, and has no truth value until x 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, P, Q, R, 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 "91 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 ¬P and read "not P", is true exactly when P is false. Conjunction, P∧Q, read "P and Q", is true exactly when both parts are true. Disjunction, P∨Q, read "P or Q", is true when at least one part is true, including when both are.

PQ¬PP∧QP∨Q
TTFTT
TFFFT
FTTFT
FFTFF

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 ab=0 then a=0 or b=0" must not exclude a=b=0, and "n is divisible by 2 or by 3" is true of 6. When the exclusive sense is wanted it is spelt out: "P or Q but not both", which is (P∨Q)∧¬(P∧Q). This is the exclusive or, sometimes written P⊕Q, 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 "x>3" is "x≤3", not "x<3": at x=3 both "x>3" and "x<3" are false, so the second cannot be the negation of the first. And "x≤3" is itself a disjunction, "x<3 or x=3". Likewise the negation of "n is even" is "n is not even", which becomes "n 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: "7 is prime but 9 is not" is P∧¬Q. Mathematical writing also hides conjunctions in chains: "0<x<1" is "0<x and x<1", and "a=b=c" is "a=b and b=c".

Compound statements need brackets, just as in arithmetic, since ¬P∧Q could mean (¬P)∧Q or ¬(P∧Q), and these differ. The convention is that ¬ applies to the smallest thing after it, so ¬P∧Q means (¬P)∧Q. For the other connectives this course uses brackets whenever there could be doubt.

The conditional

The fourth connective is the conditional, P⇒Q, read "if P then Q" or "P implies Q". P is the hypothesis (or antecedent) and Q the conclusion (or consequent).

PQP⇒Q
TTT
TFF
FTT
FFT

The first two rows need no defence. "If n is divisible by 4, then n is even" is kept by a number divisible by 4 that is even, and would be broken by one divisible by 4 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 2+2=5, then 7 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 x, if x is in the empty set then x is even", and the hypothesis is false for every x. "All the prime factors of 1 are greater than 100" is true for the same reason. A definition that says "a set of numbers is bounded below by 5 if every element is at least 5" makes the empty set bounded below by 5, 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 n, if n is divisible by 4, then n is even. It claims something about every integer, so it is true only if each instance, one conditional per integer, is true. At n=8 the instance has a true hypothesis and a true conclusion. At n=6 the hypothesis is false and the conclusion true. At n=7 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 P⇒Q into P∧Q, so the theorem would assert that n is divisible by 4. 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 4, which 6 refutes. Making only the false-false row false gives a column identical to Q, and the hypothesis would do nothing.

The conditional asserts no connection between its parts: "if 2+2=5, then 7 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 P is true, so to prove P⇒Q it is enough to assume P and show that Q follows, which is what the previous lesson did when it began "let a and b be odd".

That same row gives the negation. Since P⇒Q is false only when P is true and Q false, its negation is P∧¬Q. 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 n is prime, then n is odd", decide whether the conditional is true for n=2, n=9 and n=7, and say what this shows.

The negation is "n is prime and n is not odd", since ¬(P⇒Q) is P∧¬Q. For n=2 the hypothesis is true and the conclusion false, so the conditional is false, and its negation is true: 2 is prime and not odd. For n=9 the hypothesis is false, since 9=3×3, so the conditional is vacuously true. For n=7 both parts are true and so is the conditional. The claim "every prime is odd" is therefore false, and n=2 is the counterexample: an integer at which the negation holds.

Now you. Negate "if x>2, then x2>4", and decide whether the conditional is true for x=3, x=−3 and x=1.

Answer

The negation is "x>2 and x2≤4". At x=3 both x>2 and x2=9>4 hold, so the conditional is true. At x=−3 the hypothesis fails, so the conditional is vacuously true, even though x2=9>4. At x=1 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 x>2 then x is positive and x2=x⋅x>2x>4.

Isn't "if the Moon is made of cheese, then 2+2=4" 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, P and P⇒Q together always give Q, 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, P⟺Q, read "P if and only if Q" and often abbreviated "P iff Q". It is true when P and Q have the same truth value, and false when they differ.

PQP⇒QQ⇒P(P⇒Q)∧(Q⇒P)P⟺Q
TTTTTT
TFFTFF
FTTFFF
FFTTTT

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: P⟺Q is true where P⊕Q is false, and the reverse.

A true biconditional says that two conditions are interchangeable. "An integer n is divisible by 6 if and only if it is divisible by both 2 and 3" 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 P, P⟺P is true; if P⟺Q then Q⟺P; and if P⟺Q and Q⟺R, then P⟺R. The last fact justifies chains such as "x2−5x+6=0 if and only if (x−2)(x−3)=0 if and only if x=2 or x=3", 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 4 rows; with three there are 8; with n there are 2n, 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, P∨¬P: every statement is true or its negation is.
  • The law of non-contradiction, ¬(P∧¬P): no statement is true together with its negation.
  • The law of identity, P⇒P.

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 (x>3)∨¬(x>3) is true for every x, and so is (P∧Q)∨¬(P∧Q).

One tautology explains a remark in the previous lesson, that a system of axioms must be free of contradictions. The statement (P∧¬P)⇒Q is a tautology: its hypothesis is false in every row, so the conditional is vacuously true in every row, whatever Q 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 P1,…,Pk and conclusion C is valid when (P1∧⋯∧Pk)⇒C 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 P and P⇒Q, conclude Q. Every application of a theorem is one: the theorem is P⇒Q, and checking its hypothesis gives P.
  • Modus tollens: from P⇒Q and ¬Q, conclude ¬P.
  • Hypothetical syllogism: from P⇒Q and Q⇒R, conclude P⇒R. This is how results chain together.
  • Disjunctive syllogism: from P∨Q and ¬P, conclude Q.
  • Proof by cases: from P∨Q, P⇒R and Q⇒R, conclude R.

Two invalid patterns are common enough to have names too. Affirming the consequent argues from P⇒Q and Q to P: "if n is divisible by 4 then n is even; n is even; so n is divisible by 4", which fails at n=6. Denying the antecedent argues from P⇒Q and ¬P to ¬Q: "if n is divisible by 4 then n is even; n is not divisible by 4; so n is not even", which fails at n=6 too.

Example. Show that hypothetical syllogism is valid: ((P⇒Q)∧(Q⇒R))⇒(P⇒R) is a tautology.

With three atomic statements there are eight rows. Write H for the hypothesis (P⇒Q)∧(Q⇒R).

PQRP⇒QQ⇒RHP⇒RH⇒(P⇒R)
TTTTTTTT
TTFTFFFT
TFTFTFTT
TFFFTFFT
FTTTTTTT
FTFTFFTT
FFTTTTTT
FFFTTTTT

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 P⇒R to be false, P must be T and R must be F. For the hypothesis to be true, both P⇒Q and Q⇒R must be T. With P true, P⇒Q forces Q true; with R false, Q⇒R forces Q false. Q 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, ((P⇒Q)∧¬Q)⇒¬P is a tautology, and that affirming the consequent is not, by finding a row in which ((P⇒Q)∧Q)⇒P is false. Give an instance of the second with real numbers.

Answer

Modus tollens. For the conditional to be false, its conclusion ¬P must be F, so P is T, and its hypothesis must be T, so P⇒Q is T and ¬Q is T, which makes Q false. But then P⇒Q 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 P false and Q true. Then P⇒Q is T (vacuously) and Q is T, so the hypothesis (P⇒Q)∧Q is T, while the conclusion P is F. In that row the conditional is false, so it is not a tautology, and the argument pattern is invalid.

An instance. "If x>2 then x2>4. We have x2>4. So x>2." The premises are true for x=−3, since the conditional holds for every real number and (−3)2=9>4, but the conclusion −3>2 is false. That is the row P false, Q true.

Is there a faster way than writing out all 2n 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 n atomic statements it has 2n rows: 30 statements give over a billion rows, and 300 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 1 to 7825 cannot be split into two groups neither of which contains a Pythagorean triple a2+b2=c2, while 1 to 7824 can. The proof the computer produced was about 200 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, A and B are equivalent when A⟺B 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 ¬(P∧Q), which denies the whole conjunction, is a different thing from ¬P∧Q, where ¬ applies only to P.

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 ¬(P∧Q) and ¬P∨¬Q are equivalent, and use this to negate "x>0 and x<5".

Compute both columns in each of the four rows.

PQP∧Q¬(P∧Q)¬P¬Q¬P∨¬Q
TTTFFFF
TFFTFTT
FTFTTFT
FFFTTTT

The fourth and seventh columns agree in every row, so the two statements are equivalent. Now let P be "x>0" and Q be "x<5". The negation of P∧Q is ¬P∨¬Q, and the negations of the parts are "x≤0" and "x≥5". So the negation of "x>0 and x<5" is "x≤0 or x≥5".

Now you. Show that ¬(P∨Q) and ¬P∧¬Q are equivalent, and use this to negate "x<0 or x>1".

Answer

P∨Q is false only in the row where P and Q are both false, so ¬(P∨Q) is true in that row and false in the other three. ¬P∧¬Q is true only when ¬P and ¬Q are both true, which is the same row. The columns agree in all four rows, so the statements are equivalent. The negation of "x<0 or x>1" is therefore "x≥0 and x≤1", that is, 0≤x≤1.

The common error is to negate the parts and leave the connective alone. "Not (x>0 and x<5)" is not "x≤0 and x≥5", 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, T stands for any tautology and F for any contradiction.

NameStatementEquivalent to
Double negation¬¬PP
Commutative lawsP∧Q and P∨QQ∧P and Q∨P
Associative laws(P∧Q)∧R and (P∨Q)∨RP∧(Q∧R) and P∨(Q∨R)
Distributive lawsP∧(Q∨R)(P∧Q)∨(P∧R)
P∨(Q∧R)(P∨Q)∧(P∨R)
De Morgan's laws¬(P∧Q) and ¬(P∨Q)¬P∨¬Q and ¬P∧¬Q
Idempotent lawsP∧P and P∨PP
Absorption lawsP∧(P∨Q) and P∨(P∧Q)P
Identity lawsP∧T and P∨FP
Domination lawsP∨T and P∧FT and F
Complement lawsP∨¬P and P∧¬PT and F
Material implicationP⇒Q¬P∨Q
ContrapositiveP⇒Q¬Q⇒¬P
BiconditionalP⟺Q(P⇒Q)∧(Q⇒P)

Two of these deserve comment. Material implication says that "if P then Q" is the same as "not P, or Q": the conditional is false only when P is true and Q false, which is exactly when ¬P∨Q 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 a+bc is not (a+b)(a+c). Logic is more symmetric than arithmetic: every law in the list stays a law when ∧ and ∨ are exchanged and T and F 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: ¬(P⇒Q) is equivalent to ¬(¬P∨Q) by material implication, which is equivalent to ¬¬P∧¬Q by De Morgan, and so to P∧¬Q by double negation.

Example. Prove, using the laws, that (P⇒Q)∧(P⇒R) is equivalent to P⇒(Q∧R), and say what the equivalence means for proofs.

StepStatementReason
1(P⇒Q)∧(P⇒R)given
2(¬P∨Q)∧(¬P∨R)material implication, twice
3¬P∨(Q∧R)distributive law, read from right to left
4P⇒(Q∧R)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 P then both Q and R" it is enough to prove "if P then Q" and "if P then R" separately, and conversely. The proof that 6∣n gives both 2∣n and 3∣n in the lesson on direct proof is of this shape.

Now you. Prove, using the laws, that (P⇒R)∧(Q⇒R) is equivalent to (P∨Q)⇒R, and say what it means for proofs.

Answer
StepStatementReason
1(P⇒R)∧(Q⇒R)given
2(¬P∨R)∧(¬Q∨R)material implication, twice
3(R∨¬P)∧(R∨¬Q)commutative law, twice
4R∨(¬P∧¬Q)distributive law, read from right to left
5R∨¬(P∨Q)De Morgan's law
6¬(P∨Q)∨Rcommutative law
7(P∨Q)⇒Rmaterial implication

For proofs, it is the justification of proof by cases: to show that R follows from "P or Q", show that it follows from P and that it follows from Q. 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: (P∧Q)⇒R is equivalent to (P⇒R)∨(Q⇒R), 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 x" as 1−x, with 1 for true and 0 for false. In his system x2=x for every x, since "P and P" says no more than P, and this equation, which holds for the numbers 0 and 1 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 "x belongs to A∩B" means "x belongs to A and x belongs to B", 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 P⇒Q gives three new conditionals: the converse Q⇒P, the inverse ¬P⇒¬Q, and the contrapositive ¬Q⇒¬P. Their tables settle which say the same thing as the original.

PQP⇒Q¬Q⇒¬PQ⇒P¬P⇒¬Q
TTTTTT
TFFFTT
FTTTFF
FFTTTT

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 ¬Q⇒¬P is a proof of P⇒Q, which the lesson on contrapositive and contradiction turns into a method, while a proof of P⇒Q says nothing about Q⇒P. 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: P⇒Q is equivalent to ¬P∨Q by material implication, to Q∨¬P by commutativity, to ¬¬Q∨¬P by double negation, and so to ¬Q⇒¬P by material implication again.

Example. Write the converse, inverse and contrapositive of "if n is divisible by 6, then n is divisible by 3", and decide which are true for every integer n.

The statement is true: if n=6k for an integer k, then n=3(2k), and 2k is an integer. The converse is "if n is divisible by 3, then n is divisible by 6", which is false, since n=3 is divisible by 3 and not by 6. The inverse is "if n is not divisible by 6, then n is not divisible by 3", and n=3 refutes it too, as it must, being equivalent to the converse. The contrapositive is "if n is not divisible by 3, then n is not divisible by 6", which is true because it is equivalent to the original.

Now you. For real numbers x, write the converse, inverse and contrapositive of "if x>3, then x2>9", and decide which are true.

Answer

The statement is true: if x>3 then x is positive, so x2=x⋅x>3x>3⋅3=9. The converse, "if x2>9 then x>3", is false, since x=−4 gives x2=16>9 with x<3. The inverse, "if x≤3 then x2≤9", is false by the same x=−4. The contrapositive, "if x2≤9 then x≤3", 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 n is even then n+1 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 n is prime then n is odd", refuted by 2, and its converse, refuted by 9). When both are true, the statement and its converse together make a biconditional.

Necessary, sufficient, only if, unless

When P⇒Q holds, P is a sufficient condition for Q: having P guarantees Q. And Q is a necessary condition for P: without Q there is no P, which is the contrapositive read aloud. Divisibility by 6 is sufficient for divisibility by 3, and divisibility by 3 is necessary for divisibility by 6. These are one fact seen from its two ends. A condition that is necessary and sufficient for Q is one equivalent to it: "a necessary and sufficient condition for n to be divisible by 6 is that it be divisible by 2 and by 3."

"P only if Q" also means P⇒Q. "Only" marks the necessary condition, which is the conclusion: "n is divisible by 4 only if n is even" says divisibility by 4 cannot happen without evenness. By contrast "P if Q" means Q⇒P. The two are opposite, so together they make "if and only if": P⟺Q is the same as (P⇒Q)∧(Q⇒P), a condition both necessary and sufficient. That is why proving an "if and only if" takes two proofs, one per direction.

"P unless Q" means that if Q fails, then P holds: ¬Q⇒P, which by material implication and double negation is Q∨P. 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.

EnglishSymbols
P implies Q; if P then Q; Q if P; Q whenever PP⇒Q
P only if Q; P is sufficient for Q; Q is necessary for PP⇒Q
Q provided that P; Q follows from PP⇒Q
P unless Q¬Q⇒P, that is, P∨Q
P if and only if Q; P is necessary and sufficient for Q; P exactly when QP⟺Q
neither P nor Q¬P∧¬Q

One convention catches every newcomer. Definitions are written with "if", as in "an integer n is even if n=2k for some integer k", but a definition is always read as "if and only if". The previous lesson used its definitions in both directions, producing a k from an even number and concluding evenness from a k, 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 P or ¬Q. 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 (P∧¬Q)∨(¬P∧Q∧R). It is in conjunctive normal form (CNF) if it is a conjunction of clauses, each of which is a disjunction of literals, as in (P∨Q)∧(¬P∨R). 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 P is T, Q is F and R is T, the conjunction is P∧¬Q∧R: it is true exactly when P is true, Q is false and R 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 P T, Q F, R T it is ¬P∨Q∨¬R, 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 M of P, Q and R is true exactly when at least two of the three are true. Find a DNF and a CNF for M, and simplify them.

PQRMrow conjunctionrow disjunction
TTTTP∧Q∧R
TTFTP∧Q∧¬R
TFTTP∧¬Q∧R
TFFF¬P∨Q∨R
FTTT¬P∧Q∧R
FTFFP∨¬Q∨R
FFTFP∨Q∨¬R
FFFFP∨Q∨R

The DNF is the disjunction of the four row conjunctions of the T rows:

(P∧Q∧R)∨(P∧Q∧¬R)∨(P∧¬Q∧R)∨(¬P∧Q∧R)

and the CNF is the conjunction of the four row disjunctions of the F rows:

(¬P∨Q∨R)∧(P∨¬Q∨R)∧(P∨Q∨¬R)∧(P∨Q∨R)

Both are correct and both are clumsy. The laws shorten them. The first two terms of the DNF share P∧Q, and by the distributive law their disjunction is (P∧Q)∧(R∨¬R), which is P∧Q by the complement and identity laws. More directly, (P∧Q)∨(P∧R)∨(Q∧R) 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 M. The same reasoning applied to the CNF gives (P∨Q)∧(P∨R)∧(Q∨R): 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 (P⇒Q)⇒R from its truth table, and check them against a short form obtained with the laws.

Answer

The statement is false exactly when P⇒Q is true and R is false. With R false, P⇒Q 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

(¬P∨¬Q∨R)∧(P∨¬Q∨R)∧(P∨Q∨R)

The DNF, one term per T row (TTT, TFT, TFF, FTT, FFT), is

(P∧Q∧R)∨(P∧¬Q∧R)∨(P∧¬Q∧¬R)∨(¬P∧Q∧R)∨(¬P∧¬Q∧R)

With the laws: (P⇒Q)⇒R is equivalent to ¬(P⇒Q)∨R by material implication, and ¬(P⇒Q) is equivalent to P∧¬Q, so the statement is equivalent to (P∧¬Q)∨R. That is a DNF with two terms. It is true when R is true (four rows) or when P is T, Q is F and R is F (one more row), five rows in all, matching the table. Distributing gives the CNF (P∨R)∧(¬Q∨R), which is false exactly when R is false and either P is false or Q 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 n variables is any rule that assigns T or F to each of the 2n 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 2n rows may independently get T or F, there are 22n truth functions of n variables. For two variables that is 24=16, 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 n variables P1,…,Pn be given. If it is F in every row, it is the truth table of P1∧¬P1, 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, P∨Q is equivalent to ¬(¬P∧¬Q), 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, P∧Q is equivalent to ¬(¬P∨¬Q), so ∧ can be removed in favour of ¬ and ∨. For the third, P∨Q is equivalent to ¬P⇒Q 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, P↑Q, is defined to be equivalent to ¬(P∧Q): 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, P↑P is equivalent to ¬(P∧P), which is ¬P by the idempotent law. Second, P∧Q is equivalent to ¬¬(P∧Q), which is ¬(P↑Q), and by the first part that is (P↑Q)↑(P↑Q). 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, P↓Q, equivalent to ¬(P∨Q), 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, ¬P 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 A and B are both true in that row, then so are A∧B and A∨B. 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 ¬P is false in the row where P is true. So no statement built with ∧ and ∨ has the truth table of ¬P. □

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 A⇒B and A⟺B are also true whenever A and B 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 22n 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 n almost every truth function of n variables needs a circuit of size exponential in n. 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 n, if n is divisible by 4, then n is even" is not a conditional between two statements, since "n is divisible by 4" is an open sentence; the phrase "for every integer n" 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) 7 is a factor of 91. (b) x2≥0. (c) Factorise x2−1. (d) Every prime greater than 2 is odd. (e) 2100+1 is prime.

Solution

(a) A statement, and true: 91=7×13.

(b) Not a statement: it is an open sentence with the free variable x. It becomes a statement once x is fixed, or once a quantifier is added, as in "for every real number x, x2≥0", which is true.

(c) Not a statement: it is an instruction.

(d) A statement, and true. (A prime p>2 is not divisible by 2, since its only positive divisors are 1 and p; 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 100=25×4 has the odd divisor 25, Problem 13 of the previous lesson shows that 2100+1 is composite: it is divisible by 24+1=17. 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 ¬P∨(P∧Q) and of P⇒Q, and decide whether they are equivalent. Then show the same thing using the laws.

Solution
PQ¬PP∧Q¬P∨(P∧Q)P⇒Q
TTFTTT
TFFFFF
FTTFTT
FFTFTT

The last two columns agree in every row, so the statements are equivalent.

With the laws: by the distributive law, ¬P∨(P∧Q) is equivalent to (¬P∨P)∧(¬P∨Q). The first part is a tautology by the complement law (and commutativity), so by the identity law the whole is equivalent to ¬P∨Q, which is P⇒Q 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 2, 2 and 3 is isosceles and not equilateral (these lengths do form a triangle, since 2+2>3).

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 P be "n is prime", Q be "n is odd" and R be "n>2", for a positive integer n. Translate each sentence into symbols. (a) n is prime only if n is odd. (b) n>2 is sufficient for n to be odd. (c) Being odd is necessary for n to be prime, provided n>2. (d) n is not prime unless it is odd. (e) n is odd if it is prime and greater than 2.

Solution

(a) P⇒Q. "Only if" introduces the necessary condition, which is the conclusion. It is false for n=2.

(b) R⇒Q. False for n=4.

(c) R⇒(P⇒Q). "Being odd is necessary for being prime" is P⇒Q, and the proviso makes it conditional on R. It is true for every positive integer n.

(d) "A unless B" is ¬B⇒A. Here A is ¬P and B is Q, so the translation is ¬Q⇒¬P, the contrapositive of (a) and equivalent to it.

(e) (P∧R)⇒Q. It is equivalent to (c): by the laws, R⇒(P⇒Q) is ¬R∨¬P∨Q, and so is (P∧R)⇒Q, since ¬(P∧R) is ¬P∨¬R.

Core

5. Prove the distributive law "P∧(Q∨R) is equivalent to (P∧Q)∨(P∧R)" by a truth table. Then deduce the other distributive law, "P∨(Q∧R) is equivalent to (P∨Q)∧(P∨R)", without a table.

Hint

For the second part, apply the first law to the statements ¬P, ¬Q and ¬R, and negate both sides.

Solution
PQRQ∨RP∧(Q∨R)P∧QP∧R(P∧Q)∨(P∧R)
TTTTTTTT
TTFTTTFT
TFTTTFTT
TFFFFFFF
FTTTFFFF
FTFTFFFF
FFTTFFFF
FFFFFFFF

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 ¬P, ¬Q, ¬R in place of P, Q, R: the statement ¬P∧(¬Q∨¬R) is equivalent to (¬P∧¬Q)∨(¬P∧¬R). Equivalent statements have equivalent negations, so

¬(¬P∧(¬Q∨¬R))is equivalent to¬((¬P∧¬Q)∨(¬P∧¬R))

Apply De Morgan's laws and double negation to each side. The left side becomes ¬¬P∨¬(¬Q∨¬R), then P∨(¬¬Q∧¬¬R), then P∨(Q∧R). The right side becomes ¬(¬P∧¬Q)∧¬(¬P∧¬R), then (P∨Q)∧(P∨R). So P∨(Q∧R) is equivalent to (P∨Q)∧(P∨R).

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) (P⇒Q)⇒R is equivalent to P⇒(Q⇒R). (b) P⇒(Q⇒R) is equivalent to (P∧Q)⇒R. (c) (P⇒Q)∨(Q⇒P) is a tautology. (d) (P⟺Q)⟺R is equivalent to P⟺(Q⟺R).

Hint

Exactly one is false. For it, look for a row with P false. For (d), find a simple description of the rows in which each side is true.

Solution

(a) False. Take P false and R false, with Q either value. Then P⇒Q is true (vacuously), so (P⇒Q)⇒R has a true hypothesis and a false conclusion, and is false. But P⇒(Q⇒R) 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, P⇒(Q⇒R) is equivalent to ¬P∨(¬Q∨R), which by associativity is (¬P∨¬Q)∨R. By De Morgan's law this is ¬(P∧Q)∨R, and by material implication that is (P∧Q)⇒R. In words: "if P, then if Q then R" says the same as "if P and Q, then R". 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 (¬P∨Q)∨(¬Q∨P), which by the commutative and associative laws is (P∨¬P)∨(Q∨¬Q). 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 Q is true then P⇒Q holds, and if Q is false then Q⇒P holds.

(d) True. A biconditional A⟺B is true exactly when A and B are both true or both false. Claim: (P⟺Q)⟺R is true exactly when an odd number of P, Q, R are true. Check by cases on R. If R is true, the whole is true exactly when P⟺Q is true, that is, when P and Q are both true or both false, that is, when an even number of P, Q are true, which together with the true R makes an odd number in all. If R is false, the whole is true exactly when P⟺Q is false, that is, when exactly one of P, Q is true, again an odd number in all. The same argument, splitting on P in place of R, shows that P⟺(Q⟺R) 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 P⇒Q is ¬P⇒¬Q, and the negation of 'if n is divisible by 4, then n is even' is 'if n is not divisible by 4, then n is not even'."

Hint

A statement and its negation must have opposite truth values in every row. Check the row with P false and Q false.

Solution

In the row where P and Q are both false, P⇒Q is true (vacuously), and ¬P⇒¬Q is true too, since both its parts are true. A statement and its negation cannot both be true, so ¬P⇒¬Q is not the negation of P⇒Q. 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 P∧¬Q: the hypothesis holds and the conclusion fails. For the example, the negation of "if n is divisible by 4, then n is even" is "n is divisible by 4 and n is not even", which no integer satisfies, as it should, since the original holds for every integer. The student's version is false for n=6, which is not divisible by 4 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 A be the statement "A is a knight". Whatever A says is true exactly when A is a knight, so if A says S, then A⟺S holds.

Solution

Write A 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 S, then S is true exactly when X is a knight, so X⟺S holds.

(a) A says ¬A∨¬B, so A⟺(¬A∨¬B) holds. If A were false, the right side would have to be false too, so ¬A∨¬B would be false; but ¬A is true, so it is true. That is impossible, so A is true. Then the right side is true: ¬A∨¬B holds, and since ¬A is false, ¬B 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 D, so C⟺D. D says that exactly one of C and D is a knight, which is C⊕D, so D⟺(C⊕D). From the first, C and D have the same truth value, so C⊕D is false. Then the second says D⟺F, so D is false, and by the first C 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) ¬(P∨(¬P∧Q)) is equivalent to ¬P∧¬Q; (b) (P∧Q)∨(P∧¬Q) is equivalent to P; (c) P⇒(Q⇒P) 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, ¬(P∨(¬P∧Q)) is equivalent to ¬P∧¬(¬P∧Q). By De Morgan's law and double negation, ¬(¬P∧Q) is equivalent to P∨¬Q, so the whole is ¬P∧(P∨¬Q). By the distributive law this is (¬P∧P)∨(¬P∧¬Q). The first part is a contradiction by the complement law (with commutativity), so by the identity law (A∨F is A, after commuting) the whole is equivalent to ¬P∧¬Q.

(b) By the distributive law, (P∧Q)∨(P∧¬Q) is equivalent to P∧(Q∨¬Q). By the complement law Q∨¬Q is a tautology, and by the identity law P∧T is P.

(c) By material implication twice, P⇒(Q⇒P) is equivalent to ¬P∨(¬Q∨P). By the commutative and associative laws this is (¬P∨P)∨¬Q. The bracket is a tautology by the complement law, and by the domination law T∨¬Q is a tautology. So the statement is equivalent to a tautology, and is one. In words: if P is true, then it follows from anything.

10. Let E be the statement "exactly one of P, Q, R is true". Write E in disjunctive normal form. Then prove that

(P∨Q∨R)∧(¬P∨¬Q)∧(¬P∨¬R)∧(¬Q∨¬R)

is a conjunctive normal form for E, 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. E is true in exactly three rows: TFF, FTF and FFT. One term per row gives

(P∧¬Q∧¬R)∨(¬P∧Q∧¬R)∨(¬P∧¬Q∧R)

CNF. Call the displayed statement C. Its first clause, P∨Q∨R, is true exactly when at least one of the three is true. The clause ¬P∨¬Q is equivalent to ¬(P∧Q) by De Morgan's law, so it is true exactly when P and Q are not both true; likewise the other two clauses say that P and R are not both true, and that Q and R 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 C is true exactly when at least one and at most one is true, which is exactly when E 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 P↓Q is defined to be equivalent to ¬(P∨Q). Prove that {↓} is functionally complete, and write P∧Q and P⇒Q using ↓ alone.

Hint

Since {¬,∨} is complete, it is enough to express ¬ and ∨. Compare with the proof for NAND.

Solution

First, P↓P is equivalent to ¬(P∨P), which is ¬P by the idempotent law. Second, P∨Q is equivalent to ¬¬(P∨Q) by double negation, which is ¬(P↓Q), and by the first part that is (P↓Q)↓(P↓Q). 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, P∧Q is equivalent to ¬(¬P∨¬Q), which is ¬P↓¬Q, that is, (P↓P)↓(Q↓Q).

For ⇒: P⇒Q is equivalent to ¬P∨Q, which by the second part is (¬P↓Q)↓(¬P↓Q), that is,

((P↓P)↓Q)↓((P↓P)↓Q)

A check in one row: with P true and Q false, P↓P is F, then F↓F is T, and T↓T is F, matching P⇒Q in that row.

12. Prove that {⇒} is not functionally complete, but that {⇒,F} is, where F 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 ¬P.

Solution

Not complete. Consider the row in which every atomic statement is true. Atomic statements are true in that row, and if A and B are true in that row, then so is A⇒B, 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 ¬P is false in any row where P is true. So ¬P cannot be expressed with ⇒ alone, and {⇒} is not functionally complete.

Complete with F. The statement P⇒F is true exactly when P is false, since its conclusion is always false; so it is equivalent to ¬P. Thus both ¬ and ⇒ can be expressed with {⇒,F}, and since {¬,⇒} is functionally complete (the corollary in the section on functional completeness), so is {⇒,F}.

Adding F breaks the argument of the first part exactly where it must: F is not true in the all-true row. Reading P⇒F as "not P" is the idea behind proof by contradiction: to show ¬P, show that P 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 T∘T false and F∘F 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: T∘T is F. Suppose instead that T∘T 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 A and B are true in that row then so is A∘B. So ¬P could not be expressed, contradicting completeness.

Step 2: F∘F is T. Suppose instead that F∘F is F. Then in the row where all atomic statements are false, every statement built with ∘ is false, by the same argument. But ¬P is true in that row, so it could not be expressed, again contradicting completeness.

Step 3: the four candidates. With T∘T false and F∘F true, the connective is fixed by its values in the two middle rows, T∘F and F∘T.

  • Both T: the table is F, T, T, T, which is NAND.
  • Both F: the table is F, F, F, T, which is NOR.
  • T∘F is T and F∘T is F: the table is F, T, F, T, which is the table of ¬Q. So P∘Q is equivalent to ¬Q.
  • T∘F is F and F∘T is T: the table is F, F, T, T, so P∘Q is equivalent to ¬P.

Step 4: the last two are not Sheffer. Take the third, where A∘B is equivalent to ¬B. Claim: every statement built from atomic statements with ∘ alone is equivalent to X or to ¬X for a single atomic statement X. Atomic statements have this form. If A and B have it, say B is equivalent to X or ¬X, then A∘B is equivalent to ¬B, which is equivalent to ¬X or to X (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 P∧Q is not equivalent to any of P, ¬P, Q, ¬Q: it differs from P when P is T and Q is F, from ¬P and from ¬Q when both are T, and from Q when P is F and Q is T. (A statement involving some other atomic statement X has a truth value that changes with X, so it cannot have the table of P∧Q either.) So ∧ cannot be expressed, and this connective is not Sheffer. The fourth candidate is the same with the roles of A and B 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 P and Q using only ¬ and ⟺ is equivalent to P∧Q. Deduce that {¬,⟺} is not functionally complete.

Hint

Count the T's in the four-row truth table. Show that every statement built from P and Q with ¬ and ⟺ has an even number of them.

Solution

For a statement A built from P and Q, let t(A) be the number of rows, out of the four, in which A is true. Claim: t(A) is even for every statement built from P and Q with ¬ and ⟺.

Atomic statements. P is true in two rows and so is Q, so t(P)=t(Q)=2.

Negation. ¬A is true exactly in the rows where A is false, so t(¬A)=4−t(A), which is even if t(A) is.

Biconditional. Let A and B be statements with t(A)=a and t(B)=b even, and let c be the number of rows in which both are true. The rows in which A is true or B is true number a+b−c (the c rows where both are true would otherwise be counted twice), so the rows in which both are false number 4−a−b+c. Now A⟺B is true exactly in the rows where both are true or both are false, so

t(A⟺B)=c+(4−a−b+c)=4−a−b+2c

which is even, since a and b are even.

Every statement built from P and Q with ¬ and ⟺ is made from P and Q by finitely many such steps, each of which keeps the number of T rows even, so every such statement has t even. But P∧Q is true in exactly one row, and 1 is odd. So no such statement is equivalent to P∧Q.

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 P and Q with 0, 2 or 4 true rows; they are the truth functions that computer scientists call linear, and in Boole's algebra with 1 for T they are the sums of P, Q and 1 with arithmetic done modulo 2.