Logic


 * set;
 * element:

This section is based on the original source published at; http://en.wikibooks.org/wiki/Beginning_Rigorous_Mathematics/Basic_Logic

In this section the symbols $$P$$ and $$Q$$ denote any logical statements.

= Logical operators and Truth Tables =

Truth tables are used in two ways. Firstly to define exactly what a certain compounded statement means, and secondly to derive the properties of more complicated compounded statements. Truth tables exhaust all possible combinations of the truth of falsehood of the constituent statements in the compounded statement to yield exactly under what combinations of truth and falsehood of the constituent statements, the compound statement is true or false.

Not, Negation
We define the symbol "$$\lnot$$" to mean "not". If $$P$$ is a statement then $$\lnot P$$ is also a statement. It inverts the truth or falsehood of logical statements. In other words, if the statement $$P$$ is true, then the statement $$\lnot P$$ is false and if $$P$$ is false, then $$\lnot P$$ is true. We call $$\lnot P$$ the negation of $$P$$.

We rigorously define the symbol "$$\lnot$$" by the following truth table

Even though "not" simplest logical operator, the negation of statements is important when trying to prove that certain objects have or do not have certain properties. It makes the skill of being able to correctly negate statements an important one.

And, Conjunction
We define the symbol "$$\land$$" to mean "and". If $$P$$ and $$Q$$ are statements then $$P\land Q$$ is also a statement, is called the conjunction of $$P$$ and $$Q$$, and it reads "$$P$$ AND $$Q$$". The compound statement $$P\land Q$$ is true only when both statements $$P$$ and $$Q$$ are true.

We rigorously define the symbol "$$\land$$" by the following truth table

Or, Disjunction
We define the symbol "$$\lor$$" to mean "or". If $$P$$ and $$Q$$ are statements then $$P\lor Q$$ is also a statement, is called the disjunction of $$P$$ and $$Q$$, and it reads "$$P$$ OR $$Q$$". The compound statement $$P\lor Q$$ is true only when either $$P$$ or  $$Q$$ or both statements  $$P$$ and $$Q$$ are true.

We rigorously define the symbol "$$\lor$$" by the following truth table

If ... then, Implication
We define the symbol "$$\Rightarrow$$" to mean "implies". If $$P$$ and $$Q$$ are statements then $$P\Rightarrow Q$$ is also a statement and it reads "$$P$$ IMPLIES $$Q$$" or also "IF $$P$$ THEN $$Q$$". The compound statement $$P\Rightarrow Q$$ is false only when $$P$$ is true and $$Q$$ is false. We call $$P$$ the hypothesis and $$Q$$ the Conclusion of the implication.

We rigorously define the symbol "$$\Rightarrow$$" by the following truth table

We call the statement "$$Q\Rightarrow P$$" the converse of "$$P\Rightarrow Q$$".

Logical implication plays an important role since most theorems take on the form of an implication.

If and only if, Equivalence
We define the symbol "$$\Leftrightarrow$$" to mean "if and only if". If $$P$$ and $$Q$$ are statements then $$P\Leftrightarrow Q$$ is also a statement and it reads "$$P$$ is true if and only if $$Q$$ is true".

We rigorously define the symbol "$$\Leftrightarrow$$" by the following truth table

Basic results
In this section we will prove some basic equivalences for compounded logical statements. We say that two (compound) statements are logically equivalent when written in the same truth table, their columns are identical. Knowing how to write statements into logically equivalent statements is very useful in the sense that a statement might be difficult to prove, yet a logically equivalent statement might be easier to prove.

Lemma 1 (DeMorgan's law, part 1)
$$\lnot(P\land Q)$$ is logically equivalent to $$\lnot P \lor \lnot Q$$

Proof

Since the columns for the compound statements are identical, they are logically equivalent. QED

Proving the following theorems are left as exercises.

Lemma 2 (DeMorgan's law, part 2)
$$\lnot(P\lor Q)$$ is logically equivalent to $$\lnot P \land \lnot Q$$

Lemma 3
$$P\Leftrightarrow Q$$ is logically equivalent to $$(P\Rightarrow Q)\land(Q\Rightarrow P)$$

Lemma 4
$$\lnot(P\Rightarrow Q)$$ is logically equivalent to $$P\land(\lnot Q)$$

Lemma 5
$$P\Rightarrow Q$$ is logically equivalent to $$\lnot P\lor Q$$

Lemma 6 (Contrapositive)
$$P\Rightarrow Q$$ is logically equivalent to $$\lnot Q \Rightarrow \lnot P$$

Lemma 7
$$P\Leftrightarrow Q$$ is logically equivalent to $$\lnot P \Leftrightarrow \lnot Q$$

= Predicates and Quantifiers =

A predicate is defined to be a function mapping any set into the set $$\{T,F\}$$ where the symbols $$T$$ and $$F$$ mean 'true' and 'false' respectively. A predicate can be thought of a collection of statements, one for each element of the domain of the predicate.

For example, we may define the predicate $$P:\mathbb{Z}\to \{T,F\}$$ by $$P(x):=$$"x is an even integer". Instead of writing "$$P(5)=F$$" and "$$P(16)=T$$" we will say and write "$$P(5)$$ is false" and "$$P(16)$$ is true".

If $$P:A\to \{T,F\}$$ is a predicate, then the predicate $$\lnot P:A\to \{T,F\}$$ defined to be such that $$\lnot P(x)$$ is true exactly when $$P(x)$$ is false and $$\lnot P(x)$$ is false exactly when $$P(x)$$ is true, is called the negation of $$P$$.

There are two quantifiers denoted by the symbols "$$\forall$$" and "$$\exists$$" which read "for all" and "there exists" respectively.

Let $$P:A\to \{T,F\}$$ be a predicate and let $$B$$ be any subset of $$A$$ (subsets are discussed in the next section). Then $$\forall x\in B:P(x)$$ which reads "For all elements $$x$$ contained in $$B$$, P(x) is true." is a statement, and is defined to be true exactly when $$P(x)$$ is true for every element $$x$$ contained in $$B$$.

Similarly, $$\exists x\in B:P(x)$$ which reads "There exists an element $$x$$ contained in $$B$$ such that P(x) is true." is a statement, and is defined to be true exactly when $$P(x)$$ is true for at least one element $$x$$ contained in $$B$$.

We define the negation of statements involving quantifiers as follows $$\lnot(\forall x\in B:P(x)):=\exists x\in B:\lnot P(x)$$ and $$\lnot(\exists x\in B:P(x)):=\forall x\in B:\lnot P(x)$$

= Logical rules of inferrence =

Proving the truth of statements require knowledge of standard valid logical rules of inference, the most important of which are:

Adjunction
If $$P$$ and $$Q$$ are both true then so is $$P\land Q$$

Simplification
If $$P\land Q$$ is true then $$P$$ is true.

If $$P\land Q$$ is true then $$Q$$ is true.

Addition
If $$P$$ is true then $$P \lor Q$$ is true (regardless of the truth or falsehood of $$Q$$).

Disjunctive syllogism
If $$P \lor Q$$ is true, and $$P$$ is false then $$Q$$ is true.

If $$P \lor Q$$ is true, and $$Q$$ is false then $$P$$ is true.

Modus Ponens
If $$P \Rightarrow Q$$ is true, and $$P$$ is true, then $$Q$$ is true.

Modus Tollens
If $$P \Rightarrow Q$$ is true, and $$Q$$ is false, then $$P$$ is false.

In a mathematical proof, these rules are usually not explicitly mentioned as they have become second nature to mature students and authors of mathematics. We will be very explicit and pedantic in the proofs of some results in the following chapters, so will mention them.

Recall the meaning of the symbol "$$\in$$", which reads "is an element of" so that if $$A$$ is a set and $$x$$ an object, then $$x\in A$$ a is a statement (which is either true of false, depending on whether $$x$$ is an element of $$A$$).

= Sets and Set operations =

In the following discussion, $$A$$ and $$B$$ denote any sets.

The empty set: $$\emptyset$$
We will assume that the empty set exists, and is denoted by $$\emptyset$$. As the name suggests, the empty set contains no elements so that for any object $$x$$ the statement $$x\in \emptyset$$ is false.

Set equality
Usually there is no ambiguity when we use the symbol "=" to refer to equality between sets. It is important that equality between sets is completely different to equality between numbers.

We define the logical statement "$$A = B$$" to be true by definition when the statement "$$x\in A \Leftrightarrow x\in B$$" (which reads "$$x$$ is contained in $$A$$ if and only if $$x$$ is contained in $$B$$") is true, and false otherwise. Intuitively this means that sets are equal if and only if they contain exactly the same elements. For example, $$\{1,2,3\}=\{1,2\}$$ is false since "$$3\in \{1,2\}$$" is false. It might be helpful to check the truth table to see that "$$3\in \{1,2,3\} \Leftrightarrow 3\in \{1,2\}$$" is a false statement. It should then be clear that "$$\{5,6,7\}=\{5,6,7\}$$" is true.

Subsets
If every element of the set $$A$$ is an element of $$B$$, we then say that $$A$$ is a subset of $$B$$.

Rigorously, we say that the statement "$$A\subset B$$" is true by definition when the statement "$$x\in A \Rightarrow x\in B$$" (which reads "If $$x$$ is contained in $$A$$ then $$x$$ is contained in $$B$$") is true.

We have seen previously that the statement $$\{1,2\}=\{1,2,3\}$$ is false, however the statement $$\{1,2\}\subset \{1,2,3\}$$ is true. It should be clear that $$\{1,2,3,5\}\subset \{1,2,3,4\}$$ is false, since the statement "$$5\in \{1,2,3,5\} \Rightarrow 5 \in \{1,2,3,4\}$$" is false.

Intersection
We define the intersection of sets by the symbol "$$\cap$$". Rigorously we write "$$A\cap B := \{x|x\in A \land x\in B\}$$" which reads "The intersection of the sets $$A$$ and $$B$$ is by definition equal to the set which contains exactly the elements which are contained in both $$A$$ and $$B$$".

For example "$$\{1,2,3,4\}\cap \{1,4,5\}:=\{1,4\}$$".

We say that $$A$$ and $$B$$ are disjoint when $$A\cap B = \emptyset$$.

Union
We define the union of sets by the symbol "$$\cup$$". Rigorously we write "$$A\cup B := \{x|x\in A \lor x\in B\}$$" which reads "The union of the sets $$A$$ and $$B$$ is by definition equal to the set which contains exactly the elements which are contained in either one of $$A$$ and $$B$$".

For example "$$\{1,2,3,4\}\cup \{1,4,5\}:=\{1,2,3,4,5\}$$".

Complement
To define the complement of the set $$A$$ we assume that the set $$A$$ is a subset of some universal set $$X$$. We say "$$A$$ lives in $$X$$". Often the universal set is implicitly clear, for example when we are studying real analysis we often just assume $$X=\mathbb{R}$$ or when studying complex analysis we assume $$X=\mathbb{C}$$.

We define the complement of a set by the superscript "$$c$$". Rigorously "$$A^c := \{x \in X | \lnot x\in A\}$$" which reads "the complement of $$A$$ in $$X$$ is the set of all elements which are contained in $$X$$ and not in $$A$$".

For example, if we assume $$X=\{1,2,3,4,5\}$$ then $$\{1,5\}^c:=\{2,3,4\}$$.

Relative complement
We define the relative complement of sets by the symbol "$$\backslash$$". Rigorously, "$$A\backslash B := \{x\in A | \lnot x\in B\}$$" which reads "the relative complement of $$B$$ in $$A$$ is by definition equal to the set containing all the elements contained in $$A$$ and is not contained in $$B$$".

For example "$$\{1,2,3,4\}\backslash \{1,4,5\} := \{2,3\}$$".

Lemma 1
$$ (A = B) \Leftrightarrow (A\subset B) \land (B\subset A)$$. Which reads "A equals B if and only if A is a subset of B AND B is a subset of A"

proof As explained in the previous chapter, $$ (A = B) \Leftrightarrow (A\subset B) \land (B\subset A)$$ will be true by adjunction when both $$ (A = B) \Rightarrow (A\subset B) \land (B\subset A)$$ and $$ (A\subset B) \land (B\subset A) \Rightarrow (A = B)$$ are true.

We prove first $$ (A = B) \Rightarrow (A\subset B) \land (B\subset A)$$.

Let $$A = B$$, then by definition we have $$x\in A \Leftrightarrow x\in B$$, which is logically equivalent to $$(x\in A \Rightarrow x\in B)\land (x\in A \Rightarrow x\in B)$$. By simplification we have that $$x\in A \Rightarrow x\in B$$ is true, and that $$x\in A \Rightarrow x\in B$$ is true. Therefore by definition $$A \subset B$$, and $$B\subset A$$ are both true. By adjunction $$(A\subset B)\land(B\subset A)$$ is true. Therefore $$ (A = B) \Rightarrow (A\subset B) \land (B\subset A)$$ is true.

Conversely, we prove $$ (A\subset B) \land (B\subset A) \Rightarrow (A = B)$$.

Let $$ (A\subset B) \land (B\subset A)$$. Then, by simplification, both $$A\subset B$$ and $$B\subset A$$ are true. By definition both $$x\in A \Rightarrow x\in B$$ and $$x\in B \Rightarrow x\in A$$ are true. By adjunction, $$(x\in A \Rightarrow x\in B) \land (x\in B \Rightarrow x\in A)$$ is true, which is logically equivalent to $$x\in A \Leftrightarrow x\in B$$. Then by definition $$A=B$$ is true. Therefore $$ (A\subset B) \land (B\subset A) \Rightarrow (A = B)$$ is true. QED.

Lemma 2
$$A\subset A\cup B$$

Lemma 3
$$A\cap B\subset A$$ and $$A\cap B\subset B$$

The use of logic in proving mathematical statements
Theorems in rigorous mathematics often take on the form of implications or equivalences, therefore it is important to know how to go about prove such statements.

Implications
Looking at the truth table for implications we see that $$P\Rightarrow Q$$ is always true when $$P$$ is false. When $$P$$ is true, $$P\Rightarrow Q$$ is true, only when $$Q$$ is true and false otherwise. Therefore, proving an implication we only need to prove (by using the rules of logical inference) that $$Q$$ is true when we assume $$P$$ to be true.

Beginning a proof an implication $$P\Rightarrow Q$$, we will always write "Let $$P$$ be true." or just "Let $$P$$", and then use the above rules of inference to derive $$Q$$.

Often, conjunctions occur in the hypothesis of an implication when the truth of two or more statements imply the truth of the conclusion. Disjunctions sometimes occur in in the conclusion of implications as in the Fredholm alternative.

Equivalence
As we have shown above, the equivalence $$P\Leftrightarrow Q$$ is logically equivalent to $$(P\Rightarrow Q)\land(Q\Rightarrow P)$$, so proving that both implications, $$P\Rightarrow Q$$ and $$Q\Rightarrow P$$, are true (as explained in the previous paragraph) is sufficient to assert the truth of $$P\Leftrightarrow Q$$ (by adjunction).

Writing the proof of an equivalence is always done in two parts. We will write "We first prove $$P\Rightarrow Q$$" and then proceed to prove the statement, after which we write "Conversely, we now prove $$Q\Rightarrow P$$" and then prove that statements.

Often one of the constituent implications of the equivalence is trivial, while the other is not.

Proof by contradiction (Reductio ad absurdum)
Proof by contradiction is a very important method of proof. Proving, by contradiction, that a statement $$P$$ is true, we will assume that it is false and then derive by the above rules of logical inference the truth of a statement which is clearly false. Since we assert consistency - that statements can only be either true or false - there must be a problem with our argument. This problem is the assumption that $$P$$ is false, therefore $$P$$ must be true.

To begin a proof by contradiction we will write "We will prove that $$P$$ is true. Suppose, to the contrary that $$\lnot P$$ is true". Then by logical inference and the assumption we derive the truth of a statement $$Q$$ which will clearly be false, at which point we will write "But $$Q$$ is in contradiction with $$\lnot Q$$, therefore $$P$$ must be true."