Introductory Logic

The materials on this page provide an overview of basic logic. This is a largely informal discussion; more rigorous treatments are found in later notes.

This introductory chapter provides an overview of basic logic.

Propositions

Informally, a proposition is a sentence that can be meaningfully assigned a true or false value. For the sake of just getting started, that's all it is. Propositions can be connected with logical connectives to create compound propositions. For example, the propositions "xx is less than or equal to 4" and "ss is a member of AA but not a member of BB" are examples of compound propositions.

Propositional Formulas

Just as the proposition "x{x} plus y{y} equals one" can be translated to x+y=1,{x + y =1,} the proposition "If p{p} then q{q}" can be expressed symbolically as:

pq p \nc q

The expression above is called a propositional formula. It consists of the propositional variables p{p} and q,{q,} and the logical operator .{\nc.} Let's see what logical operators we have available.

Negation

The operator ¬{\neg} is called logical negation. It takes a single proposition as an operand, and returns the opposite of the operand's truth value. Here's its truth table:

pp¬p{\neg p}
TF
FT

Computer science often refers to the logical negation as the not-expression. A helpful way to think about the negation (and all the other logical operators) is in terms of sets.

Double Negatives

The double negative property provides that, given a proposition pp, the negation of the negation of pp is simply pp. We can see this to be the case from the truth table for ¬(¬p){\neg (\neg p)}:

pp¬p{\neg p}¬(¬p){\neg (\neg p)}
TFT
FTF

Conjunction

The logical connective {\land} is called the conjunction. If p{p} and q{q} are propositions, then the conjunction of p{p} and q{q} is "p{p} and q{q}," denoted pq.{p \land q.} As a truth table:

p{p}q{q}pq{p \land q}
TTT
TFF
FTF
FFF

In computer science, the conjunction is often referred to as the and-expression.

Expression: But

The word but is just another word for and in logic. For example, consider the proposition

“It is not hot but it is sunny.”\string{\text{It is not hot but it is sunny.}}

From the perspective of propositional logic, this proposition is no different from saying

“It is not hot and it is sunny.”\string{\text{It is not hot and it is sunny.}}

Encapsulating the component propositions to variables:

h=“It is hot.”{h = \string{\text{It is hot.}}}

s=“It is sunny.”{s = \string{\text{It is sunny.}}}

In propositional logic, we express this proposition as

¬hs. \neg h \land s.

Negated Conjunction

One of the most important propositional formulas in real-world logic applications is the negated conjunction. In natural language, the negated conjunction often takes the form:

not p and q \string{\text{not $p$ and $q$}}

This is a bit ambiguous in propositional logic — are we saying ((not pp) and (qq)), or are we saying (not pp and not qq)? In most everyday usage, it's the latter:

not p and not q \string{\text{not $p$ and not $q$}}

Thus, as a propositional formula, we have:

¬(pq) \neg(p \land q)

In computer science, this is propositional formula is often called a nand-expression. As we'll see later, it turns out that if a system has the nand-expression as a primitive, the system can derive all of the other logical connectives.

Inclusive Disjunction

The logical connective OR is the logical disjunction. Let pp and qq be propositions. The disjunction of pp and qq is "pp OR qq," denoted pq.{p \lor q.} If, and only if, pp is true, qq is true, or both pp and qq are true, then pq{p \lor q} is true. Otherwise, if both pp and qq are false, then pq{p \lor q} is false.

As a truth table:

ppqqpq{p \lor q}
TTT
TFT
FTT
FFF

Note that this definition of OR differs from our more common usage of or, which generally denotes "one or the other, but not both." This common usage of or is called the exclusive or. In mathematics and computer science, we use the inclusive or by default — "one or the other, or both." When the exclusive or is used, mathematicians and computer scientists will make it explicit with sentence structures such as "AA or BB but not both," or, occassionally, "Either AA or BB." The exclusive or (XOR) is covered in later sections.

Negated Inclusive Disjunction

The negation of a disjunction is called the negated disjunction. In everyday language, it often takes the form neither x{x} nor y.{y.}

negated disjunction. Let p{p} and q{q} be propositions. Then:

¬p¬q \neg p \land \neg q

is the negated disjunction of p{p} and q,{q,} read "Neither p{p} nor q.{q.}" We may also express the negated disjunction as:

¬p  q. \neg p \lnor q.

In computer science, the negated disjunction is often called a nor-expression.

Exclusive Disjunctions

The logical connective XOR, is the exclusive disjunction (the exlusive or). Given propositions pp and qq, the exlusive disjunction of pp and qq is "Either pp or qq," or "pp or qq but not both." It is denoted pq{p \oplus q}.

The proposition pq{p \oplus q} is true if, and only if, pp is true or qq is true, but not both. If (a) both pp and qq are true, or (b) both pp and qq are false, then pq{p \oplus q} is false.

ppqqpq{p \oplus q}
TTF
TFT
FTT
FFF

Note that pq{p \oplus q} is the same proposition as (pq)¬(pq).{(p \lor q) \land \neg (p \land q).} We can verify this with a truth table:

ppqqpq{p \lor q}pq{p \land q}¬(pq){\neg (p \land q)}(pq)¬(pq){(p \lor q) \land \neg (p \land q)}pq{p \oplus q}
TTTTFFF
TFTFTTT
FTTFTTT
FFFFTFF

Evaluation Order

Compound propositions themselves can be connect to form more complicated expressions:

¬pq(¬pq)¬(pq)¬((pq)(p(p¬q))) \neg p \lor q \\ (\neg p \lor q) \land \neg (p \lor q) \\ \neg ((p \land q) \lor (p \land (p \lor \neg q)))

When evaluating these more complicated expressions, we follow a convention called the Boolean order of operations:

  1. Parenthesized expressions are evaluated first, following these rules.
  2. Negations are evaluated second.
  3. Conjunctions are performed third.
  4. Inclusive/exclusive disjunctions are performed last.

An interesting thing to note is that this is purely a convention. We could have used an entirely different order, but this is the order most people have agreed on.

Logical Equivalence

The propositions "2 is greater than 1" and "1 is less than 2" are two different ways of saying the same thing. This is because of the definitions of the words “greater than” and “less than.” Both propositions, together, can only be: (1) both true, or (2) both false. In other words, if the propositions were connected with a logical connective and evaluated in a truth table, their truth values would be identical.

For example, suppose pp and qq are propositions. The compound propositions pq{p \land q} and qp{q \land p} have the same truth values:

p{p}q{q}pq{p \land q}qp{q \land p}
TTTT
TFFF
FTFF
FFFF

When two proposition forms have the same truth values, we say that they are logically equivalent. More formally, two proposition forms are logically equivalent if, and only if, they have identical truth values for each possible substitution of propositions for their proposition variables. The logical equivalence of proposition forms pp and qq is denoted by writing pq.{p \equiv q.}

Because of logical equivalence, there are logical properties we can use in all situations. We will explore some tactics for evaluating logical equivalences once we've covered conditonals.

De Morgan's Laws

Consider the following proposition:

Apples are red and sweet.

As we know, this is a compound proposition:

(1) Apples are red.

(2) Apples are sweet.

For the proposition to be false, one or both of (1) and (2) must be false. That is,

Apples are not red and sweet.

Apples are red and not sweet

Apples are not red and are not sweet.

These propositions can be reduced to a single proposition:

Apples are not red or are not sweet."

Similarly, consider the proposition:

Apples are red or green.

Like the previous proposition, this is a compound proposition consisting of two propositions:

(1) Apples are red

(2) Apples are green.

Thus, for the compound proposition to be false, both (1) and (2) must be false, since a disjunction is false if, and only if, both of its component propositions are false. The negation then is:

Apples are not red and are not green.

De Morgan's laws formalize this reduction. The negation of a conjunction is logically equivalent to a disjunction, where each component proposition is negated. The negation of a disjunction is logically equivalent to a conjunction where each component proposition is negated.

de morgan's laws. Let p{p} and q{q} be propositions. Then:

¬(pq)¬p¬q¬(pq)¬p¬q \eqs{ & \neg (p \land q) \equiv \neg p \lor \neg q \\[1em] & \neg (p \lor q) \equiv \neg p \land \neg q }

A truth table demonstrates the logical equivalences:

ppqq¬p{\neg p}¬q{\neg q}pq{p \land q}¬(pq){\neg (p \land q)}¬p¬q{\neg p \lor \neg q}
TTFFTFF
TFFTFTT
FTTFFTT
FFTTFTT

The negation of a disjunction is often written in the form of neither nor. Consider the proposition

Cats are sympathetic or lively.

The negated proposition is:

Cats are not sympathetic and are not lively.

Style, not logic, leads to the more common form:

Cats are neither sympathetic nor lively.

Tautology

A tautology is a propositional formula that always reduces to true, regardless of its component propositions's truth values. A proposition whose form is a tautology is called a tautological proposition. For example, consider the proposition:

Beijing is the capital of China or Beijing is not the capital of China.

Let's suppose:

p=Beijing is the capital of China. p = \text{Beijing is the capital of China.}

As a propositional formula:

p¬p p \lor \neg p

As a truth table:

pp¬p\neg pp¬p{p \lor \neg p}
TFT
FTT

We see that p¬p{p \lor \neg p} will always be true, regardless of what truth values are assigned to pp. Thus, we say that p¬p{p \lor \neg p} is a tautology:

(p¬p) \top (p \lor \neg p)

The symbol \top is called the verum symbol, and means "always true".

Contradictions

In contrast to the tautology, a contradiction is a propositional formula that always reduces to false, regardless of the truth values of the individual propositions substituted for the propositional form's variables. For example, consider the proposition:

Dogs are cute and dogs are not cute.

Suppose:

d=Dogs are cute. d = \text{Dogs are cute.}

As a propositional formula:

d¬d. d \land \neg d.

As a truth table:

dd¬d\neg dd¬d{d \land \neg d}
TFF
FTF

We see that d¬d{d \land \neg d} is always false, regardless of the truth value of d{d}. Thus, we say that d¬d{d \land \neg d} is a contradiction. We denote this fact with the logical notation:

(d¬d) \bot (d \land \neg d)

The symbol {\bot} is the falsum symbol, and means "always false."

Conditional Propositions

When we reason from a hypothesis to a conclusion, we make a deduction. This act is embodied in the proposition:

If p then q. \text{If ${p}$ then ${q.}$}

We call this proposition a conditional and we denote it as:

pq \large p \nc q

The symbol {\nc} is a logical connective just like {\land}, {\lor}, ¬{\neg}, etc. The proposition p{p} is called the sufficient condition, and the proposition q{q} is called the necessary condition.1.

When Is a Conditional False?

Consider the following proposition:

If Paris picks Hera, then there will be no war.

When is this proposition false? It is false if, and only if, Paris picks Hera and there is a war (i.e., the sufficient condition is true and the necessary condition is false). Otherwise, the conditional pq{p \nc q} is true.

p{p}q{q}pq{p \nc q}
TTT
TFF
FTT
FFT

If a conditional proposition's necessary condition is true because its sufficient condition is false, we say that the proposition is vacuously true. For example, consider the proposition:

If one is less than zero, then one plus one is two.

Clearly, the sufficient condition is false, and the necessary condition is true. The proposition, however, is vacuously true. To see why we vacuous truth sense, let's consider a logical equivalence of an implication.

Implications as Logical Disjunctions

The conditionals is logically equivalent to disjunctions. In fact, this is apparent from every day speech. Consider the proposition:

Either you study or you receive poor grades.

Let's rewrite this symbolically using the following variables:

VariableSignified
¬p{\neg p}you study{{\text{you study}}}
p{p}you do not study{{\text{you do not study}}}
q{q}you receive poor grades{{\text{you receive poor grades}}}

Using the variables above, we have the propositional formula:

(¬p)q (\neg p) \lor q

Now consider the proposition is:

If you do not study, then you receive poor grades.

Symbolically:

sr. s \nc r.

Let's look at their truth tables.

ppqq¬p{\neg p}pq{p \nc q}(¬p)q{(\neg p) \lor q}
TTFTT
TFFFF
FTTTT
FFTTT

Both pq{p \nc q} and ¬pq{\neg p \lor q} have the same truth values; they are logically equivalent.Similarly, if qp,{q \nc p,} then (qp)((¬q)p).{(q \nc p) \equiv ((\neg q) \lor p).}

qqpp¬q{\neg q}qp{q \nc p}(¬q)p{(\neg q) \lor p}
TTFTT
TFFFF
FTTTT
FFTTT

Accordingly, we have the following logical equivalence:

lemma. Given propositions p{p} and q,{q,}

pqq(¬p) p \nc q \equiv q \lor (\neg p)

or

pq(¬p)q p \nc q \equiv (\neg p) \lor q

Negative Implications

Let's take a closer look at that equivalence (pq)(¬pq).{(p \nc q) \equiv (\neg p \lor q).} If we negate both sides, we get:

¬(pq)¬((¬p)q). \neg (p \nc q) \equiv \neg ((\neg p) \lor q).

Applying De Morgan's laws,

¬(pq)¬((¬p)q). \neg (p \nc q) \equiv \neg ((\neg p) \lor q).

By the double negative law, we have

¬(pq)p(¬q). \neg (p \nc q) \equiv p \land (\neg q).

Therefore, it follows that

¬(pq)(p¬q). \neg (p \nc q) \equiv (p \land \neg q).

In other words, the negation of if p{p} then q{q} is p{p} and not q{q}. Let's see an example.

If I timely submit my assignment, I will not lose points.

I timely submit my assignment, but I lose points.

For those fond of Victorian horror:

If Dracula is a man, then Dracula is human.

Dracula is a man but not human.

Accordingly, we have the following theorem:

lemma. Given propositions p{p} and q,{q,}

¬(pq)    ¬q(¬p)    (¬q)p. \neg (p \nc q) ~~ \equiv ~~ \neg q \lor (\neg p) ~~ \equiv ~~ (\neg q) \land p.

The Contrapositive

A particularly useful equivalence is that between a conditonal and its contrapositive. Consider the proposition:

If I go to class, then I will attend lecture.

The contrapositive of this proposition is:

If I do not attend lecture, then I do not go to class.

contrapositive. Let p{p} and q{q} be propositions. Then

pq     p \nc q ~~\equiv~~ \not q \nc \not p

We call the proposition {\not q \nc \not p} the contrapositive of pq.{p \nc q.}

We can verify the logical equivalence claimed with a proof table. Suppose a{a} and b{b} are propositions:

aabb¬b{\neg b}¬a{\neg a}ab{a \nc b}¬b¬a{\neg b \nc \neg a}
TTFFTT
TFTFFF
FTFTTT
FFTTTT

The fact that a conditional's contrapositive is logically equivalent to the conditional is a valuable asset. Often, proving a conditional proposition's contrapositive is much easier than proving the conditional proposition itself.

The Converse

The converse of a proposition is formed when the proposition's necessary and sufficient conditions are switched:

PropositionConverse
If Bo is a horse, then Bo is a mammal.If Bo is a mammal, then Bo is a horse.

converse. Let p{p} and q{q} be propositions. Then the converse of pq{p \nc q} is the proposition

qp. q \nc p.

We may also denote the converse as

p    q p \impliedby q

which is read as "q{q} is implied by p{p}."

It's very important to understand that the converse of a conditional is not logically equivalent to the conditional. We can see that this is true with a truth table. Let p{p} and q{q} be propositions:

ppqqpq{p \nc q}qp{q \nc p}
TTTT
TFFT
FTTF
FFTT

We will revisit the converse when we examine another propositional formula called the biconditional.

The Inverse

When we negate the sufficient and necessary conditions of conditional proposition while keeping their order in place, we get the conditional's inverse.

inverse. Let p{p} and q{q} be propositions. Then the inverse of pq{p \nc q} is

¬q¬p \neg q \nc \neg p

For example:

PropositionInverse
If Sam entered the home, then she is guilty of burglary.If Sam did not enter the home, then she is not guilty of burglary.

Like the converse, the inverse of a conditional is not logically equivalent to the conditional:

ppqq¬p{\neg p}¬q{\neg q}pq{p \nc q}(¬p)(¬q){(\neg p) \nc (\neg q)}
TTFFTT
TFFTFT
FTTFTF
FFTTTT

Equivalence of Converse and Inverse

Although both the converse and inverse of a conditional are not logically equivalent to the conditional, the converse of a conditional is logically equivalent to the inverse of a conditional, and vice versa.

ppqq¬p{\neg p}¬q{\neg q}pq{p \nc q}qp{q \nc p}(¬p)(¬q){(\neg p) \nc (\neg q)}
TTFFTTT
TFFTFTT
FTTFFFF
FFTTFTT

Idiom: Only If

The idiom only if introduces a necessary condition. In other words, when we say "A only if B", we are saying "If A occurs, B MUST occur;" that is, "If b does not occur, a does not occur."

Formally, given propositions aa and bb, the proposition "aa only if bb" is denoted as:

ab a \nc b

or, equivalently,

(¬b)(¬a) (\neg b) \nc (\neg a)

The Biconditional

A biconditional proposition (a "biconditional") is a conditional proposition where both component propositions are the necessary and sufficient conditions. The biconditional most often takes the form "pp if, and only if, qq". The words if and only if are sometimes abbreviated:

“iff” \string{\text{iff}}

We will follow this convention. The biconditional pq{p \iff q} is true if both pp and qq have the same true values and is false if pp and qq have opposite truth values. The biconditional has the truth table:

ppqqpq{p \iff q}
TTT
TFF
FTF
FFT

Consider the following truth table:

ppqqpq{p \nc q}qp{q \nc p}pq{p \iff q}(pq)(qp){(p \nc q) \land (q \nc p)}
TTTTTT
TFFTFF
FTTFFF
FFTTTT

Observe that the biconditional "pp iff qq" is logically equivalent to "pp if qq and qq if pp." In other words, the biconditional is logically equivalent to the conjunction of the conditional and its converse. Symbolically:

(pq)((pq)(qp)) (p \iff q) \equiv ((p \nc q) \land (q \nc p))

This is helpful result. Biconditionals are much easier to prove or work with when they are reduced to the conditional and its converse.

Common Equivalences

The table below provides some helpful logical equivalences.

and-identityp{p \land \top}{\equiv}p{p}
or-identityp{p \lor \bot}{\equiv}p{p}
tautological dominationp{p \lor \top}{\equiv}{\top}
falsehoodp{p \land \bot}{\equiv}{\bot}
or-indempotencypp{p \lor p}{\equiv}p{p}
and-indempotencypp{p \land p}{\equiv}p{p}
double negation¬(¬p){\neg (\neg p)}{\equiv}p{p}
or-commutativitypq{p \lor q}{\equiv}qp{q \lor p}
and-commutativitypq{p \land q}{\equiv}qp{q \land p}
or-association(pq)r{(p \lor q) \lor r}{\equiv}p(qr){ p \lor (q \lor r)}
and-association(pq)r{(p \land q) \land r}{\equiv}p(qr){p \land (q \land r)}
or-distributionp(qr){p \lor (q \land r)}{\equiv}(pq)(pr){(p \lor q) \land (p \lor r)}
and-distributionp(qr){p \land (q \land r)}{\equiv}(pq)(pr){(p \land q) \lor (p \land r)}
or-absorptionp(pq){p \lor (p \land q)}{\equiv}p{p}
and-absorptionp(pq){p \land (p \lor q)}{\equiv}p{p}
natural tautologyp(¬p){p \lor (\neg p)}{\equiv}{\top}
natural contradictionp(¬p){p \land (\neg p)}{\equiv}{\bot}
conditional-reductionpq{p \nc q}{\equiv}¬pq{\neg p \lor q}
contrapositivepq{p \nc q}{\equiv}¬q¬p{\neg q \nc \neg p}
or-reductionpq{p \lor q}{\equiv}¬pq{\neg p \nc q}
and-reductionpq{p \land q}{\equiv}¬(p¬q){\neg(p \nc \neg q)}
negated conditional¬(pq){\neg(p \nc q)}{\equiv}p¬q{p \land \neg q}
conditional conjunction(pq)(pr){(p \nc q) \land (p \nc r)}{\equiv}p(qr){p \nc (q \land r)}
(pr)(qr){(p \nc r) \land (q \nc r)}{\equiv}(pq)r{(p \lor q) \nc r}
conditional disjunction(pq)(pr){(p \nc q) \lor (p \nc r)}{\equiv}p(qr){p \nc (q \lor r)}
(pr)(qr){(p \nc r) \lor (q \nc r)}{\equiv}(pq)r{(p \land q) \nc r}
biconditional reductionpq{p \iff q}{\equiv}(pq)(qp){(p \nc q) \land (q \nc p)}
pq{p \iff q}{\equiv}¬p¬q{\neg p \iff \neg q}
pq{p \iff q}{\equiv}(pq)(¬p¬q){(p \land q) \lor (\neg p \land \neg q)}
biconditional negation¬(pq){\neg(p \iff q)}{ \equiv}p¬q{p \iff \neg q}

Predicates

Consider the following argument:

(1) Every man is mortal.

(2) Socrates is a man.

(3) Therefore, Socrates is mortal.

Propositional logic isn't well-equipped to handle arguments of this form. What we need is a metalanguage that can more concisely handle sentences that use words like "is", "every", "all", "never", etc. The metalanguage we use to express such sentences is called predicate logic.

For example, consider the sentence:

Smoking is unhealthy.

This sentence has two parts, an argument and a predicate:

Smokingargument{\tnote{\text{Smoking}}{\text{argument}}} is unhealthy.predicate{\tnote{\text{is unhealthy.}}{\text{predicate}}}

We express predicates with the following notation form:

predicate(argument) \sf{predicate}(\sf{argument})

More explicitly:

predicate. The sentence

p(x1,x2,,xn) p(x_1,x_2,\ldots,x_n)

is a proposition that asserts:

For each xi, i=1,2,,n{x_i,~i=1,2,\ldots,n} p(x){p(x)} is true.

Each xi{x_i} is called an argument, and p{p} is called a predicate.

For example, the sentence

Smoking is unhealthy

can be expressed as:

u(s)u := “is unhealthy”s := “smoking” \eqs{ \sf{u(s)} \\ \sf{u}&~:=~\string{is unhealthy}\\ \sf{s}&~:=~\string{smoking} \\ }

In the notation above, the symbol :={:=} means “defined as.”{\string{defined as.}}

Limitations to Predicates

Predicates allow us to express the notions of “is”{\string{is}} and “are”.{\string{are}.} However, if we think about the way we categorize objects in the real world, we'd realize that categorize in several ways:

Some ... (is/are) (not) P{\sf{P}}

All .. (is/are) (not) P{\sf{P}}

That is, we describe objects as either all having some property P,{\sf{P},} or only some objects as having a property P.{\sf{P}.} We need to distinguish between these types of propositions to avoid ambiguity and to be more precise.

Universal Quantification

A claim of the form:

All x{x} are y.{y.}

is called a universal quantification. Because its a description of the state of the world, it is, in fact, a proposition. We use the notation below to express universal quantification.

universal quantification. The proposition:

x[P(x)] \forall \sf{x} \ix{\sf{P}(x)}

is a universal quantification, read

for all xP(x) is true. \string{for all $\sf{x}$, $\sf{P}(x)$ is true.}

For example, consider the proposition:

x+1>x x + 1 \gtn x

In predicate logic, we express this with the logical formula:

x[x+1>x] \forall x \ix{x + 1 \gtn x}

Let's consider another example. Suppose we had the statement:

x2{x^2} is greater than or equal to 0.{0.}

As a logical formula:

x[x2>=0]{\forall x \ix{x^2 \gte 0}}

Alternatively, we may also write:

x[x2=0x2>0]{\forall x \ix{x^2 = 0 \lor x^2 \gtn 0}}

Existential Quantification

A sentence of the form:

Some X{X}s are Y{Y}s.

is called an existential quantification. In the world of predicate logic, we interpret these sentences as saying:

There exists an X{X} that is not a Y.{Y.}

Why do we interpret them this way? Because it ties well to our previous notation for universal quantification. When we say that there exists an X{X} that is not a Y,{Y,} we're effectively saying:

For all X{X}, there is at least one X{X} that does not have property P.{\sf{P}.}

Thus, we have the following definition:

existential quantification. The proposition:

x[P(x)] \exist \sf{x} \ix{ \sf{P(x)}}

is an existential quantification, read:

there exists an x, such that P(x) is true. \string{there exists an $\sf{x}$, such that $\sf{P(x)}$ is true.}

Footnotes

  1. In the order of operations, the logical connective {\nc} is performed last.