Discrete Mathematics: Logic and Proofs
Logic and Proofs
Purpose of Logic
Logic provides a mathematical way to represent and reason about statements. It is useful in several areas of computer science:
Digital electronics: Logical statements can represent the behavior of circuits and computer components.
Programming: Logic helps clarify what conditions, loops, and other program structures mean.
Proofs and algorithms: Logical reasoning is used to establish that mathematical claims are true and that algorithms behave correctly.
Two major forms of logic are propositional logic and predicate logic. Propositional logic represents complete declarative statements. Predicate logic extends it by including variables, predicates, and quantifiers.
Propositional Logic
Propositions and Propositional Variables
A proposition is a declarative statement that is either true or false. For example:
“Delhi is the capital of India.”
“Delhi is in the north of India.”
Propositional variables, usually written as p, q, or r, stand for propositions. For example:
Let p mean “Delhi is the capital of India.”
Let q mean “Delhi is in the north of India.”
Each proposition has one of two truth values: true or false.
Logical Connectives
Logical connectives combine or modify propositions. The main connectives are:
Negation: ¬p, read “not p.” It reverses the truth value of p.
Conjunction: p∧q, read “p and q.” It is true only when both propositions are true.
Disjunction: p∨q, read “p or q.” In propositional logic, “or” is normally inclusive: it is true when at least one proposition is true, including when both are true.
Implication: p→q, read “if p, then q.”
Equivalence: p↔q, read “p if and only if q.” It is true when p and q have the same truth value.
A connective may combine propositions into a compound proposition. For example, if p and q are the propositions above, then p∧q means “Delhi is the capital of India and Delhi is in the north of India.”
Truth Tables
A truth table shows the truth value of a compound proposition for every possible combination of truth values of its component propositions.
With two propositions, p and q, there are four possible combinations. With one proposition, there are two. In general, a truth table for n variables has 2n rows.
Negation
Negation reverses the truth value of its proposition:
If p is true, then ¬p is false.
If p is false, then ¬p is true.
Conjunction
The conjunction p∧q is true only when both p and q are true. If either proposition is false, the conjunction is false.
Disjunction
The disjunction p∨q is true when at least one of p and q is true. It is false only when both are false.
Implication
The implication p→q is false only when p is true and q is false. In every other case, it is true.
The proposition p is called the antecedent and q the consequent. The meaning of implication can be summarized as follows:
When p is true, q must also be true for the implication to hold.
When p is false, the implication is considered true, regardless of whether q is true or false.
Thus, p→q does not assert that p or q is true by itself. It asserts that a true p cannot be paired with a false q.
Equivalence
The equivalence p↔q is true when both propositions have the same truth value:
If both are true, the equivalence is true.
If both are false, the equivalence is true.
If one is true and the other is false, the equivalence is false.
Equivalence can be expressed using two implications:
This means that each proposition implies the other.
Evaluating Compound Propositions
For a compound proposition containing several connectives, intermediate columns can be added to a truth table. Each subexpression is evaluated first, and the resulting truth values are then used to evaluate larger parts of the expression.
For example, to compare p↔q with (p→q)∧(q→p):
Create columns for p and q and list their possible truth values.
Evaluate p→q.
Evaluate q→p.
Combine those results using ∧.
Compare the resulting column with the column for p↔q.
If the two columns match in every row, the propositions are logically equivalent.
Tautologies and Contradictions
A tautology is a compound proposition that is true under every possible assignment of truth values to its variables. Its truth-table column contains only true values.
A contradiction is a compound proposition that is false under every possible assignment of truth values. Its truth-table column contains only false values.
A proposition that is true in some cases and false in others is neither a tautology nor a contradiction.
Logical Equivalence and Properties
Two propositions are logically equivalent when they have the same truth value in every possible case. A truth table can establish equivalence by showing that their columns match in every row.
For example, the commutative property states that changing the order of the operands does not change the result of conjunction or disjunction:
Other useful equivalences include the De Morgan laws:
These laws describe how negation changes a conjunction into a disjunction, or a disjunction into a conjunction, while negating each component.
Logical equivalence is stronger than merely having the same truth value in one particular example: it must hold for every possible truth-value assignment. It can be verified by constructing a truth table.
Predicate Logic
Predicates and Variables
Predicate logic represents statements involving variables. A predicate is an expression that becomes a proposition once values are assigned to its variables.
For example, let P(x) mean “x is a student.” The expression P(x) is not yet a complete proposition because the value of x has not been specified.
Substituting a particular value produces a proposition:
P(a) means “a is a student.”
P(b) means “b is a student.”
A predicate can have multiple variables. For example, let Q(x,y) mean “x+y=3.” Assigning values to both variables makes it a proposition, such as Q(1,2).
Predicate logic therefore extends propositional logic: a predicate with its variables assigned specific values becomes a proposition that can be evaluated as true or false.
Universes of Discourse
A universe of discourse, also called a domain, is the set of values that a variable is allowed to represent. The domain must fit the predicate being discussed.
For example:
If P(x) means “x is a student,” the domain might be a set of people.
If Q(x) concerns whether x is even, the domain might be the integers.
The domain may be stated explicitly, or it may be understood from context. The truth of a quantified statement depends on its domain: changing the domain can change whether the statement is true.
Quantifiers
Quantifiers specify how widely a predicate applies.
Universal quantifier
The universal quantifier, written ∀, means “for all” or “for every.”
This says that P(x) is true for every value of x in the domain.
For example, if the domain is the integers and P(x) means “x+1 is an integer,” then ∀xP(x) is true.
Existential quantifier
The existential quantifier, written ∃, means “there exists at least one.”
This says that at least one value of x in the domain makes P(x) true.
The statement does not require the predicate to hold for every value; one example in the domain is sufficient.
Combining Predicates
Predicates can be connected with the propositional connectives. For example,
is true for assigned values of x and y when both R(x) and Q(y) are true. The connective operates on the truth values of the predicate expressions after their variables are assigned values.
In a quantified expression, a quantifier applies to a scope: the part of the expression governed by that quantifier. Parentheses can make the scope clear.
For example:
Here, the quantifier ∀x governs the expression inside the parentheses. It does not quantify over y; y would need its own quantifier or an assigned value.
In expressions with several variables and quantifiers, each variable’s scope must be identified carefully. A quantifier governs the predicate expression that follows it within its scope, rather than automatically applying to every variable mentioned elsewhere.
Negating Quantified Statements
Negation changes the meaning of a quantified statement. The key rules are:
The negation of “P(x) holds for every x” means “there is at least one x for which P(x) does not hold.”
Similarly,
The negation of “there exists an x for which P(x) holds” means “for every x, P(x) does not hold.”
For instance, if the domain is the integers and P(x) means “x is even,” then the negation of “every integer is even” is “there exists an integer that is not even.”
These rules are essential when translating the negation of a sentence into a logically equivalent form. A common error is to negate the predicate but leave the quantifier unchanged; negating a quantifier changes universal to existential, or existential to universal.
The De Morgan laws also apply to compound statements. When a negation is moved inside a conjunction or disjunction, the connective switches:
Here, A and B can be propositions or predicate expressions. For a larger expression, the negation can be moved inward step by step, applying the relevant rule at each stage.
Rules of Inference
What Rules of Inference Do
A rule of inference is a valid pattern for deriving a conclusion from premises. A proof begins with statements assumed or established to be true, then uses valid inference steps to reach a conclusion.
A horizontal line is often used to separate premises from a conclusion. For example,
means that if both p and q are true, then p∧q can be concluded.
A valid rule of inference must preserve truth: whenever all of its premises are true, its conclusion must also be true.
Basic Inference Rules
Conjunction introduction
If both p and q are true, their conjunction is true:
Simplification
If p∧q is true, then each component is true. In particular:
The same reasoning permits the conclusion q.
Addition
If p is true, then p∨q is true, regardless of the truth value of q:
Modus ponens
Modus ponens applies an implication to its antecedent:
If p→q is true and p is true, then q must be true. This follows from the truth condition for implication: an implication cannot be true when its antecedent is true and its consequent is false.
For example, if “a number is even” implies “it is divisible by 2,” and a particular number is even, then that number is divisible by 2.
Modus tollens
Modus tollens uses the negation of an implication’s consequent to infer the negation of its antecedent:
If p would imply q, but q is false, then p cannot be true.
The difference between the two main implication rules is:
Modus ponens: affirms the antecedent and concludes the consequent.
Modus tollens: denies the consequent and concludes the negation of the antecedent.
Invalid Inferences
Not every conclusion that seems plausible follows from its premises. For example, the following inference is invalid:
A disjunction can be true because q is true even when p is false. For instance, if p is false and q is true, then p∨q is true but p is not. A valid inference must work for every assignment of truth values satisfying its premises, not just some assignments.
Inferences Involving Predicates
The same reasoning patterns can be applied to predicates. Suppose:
P(x) means “x is even.”
Q(x) means “x is divisible by 2.”
If P(x)→Q(x) and P(x) are both established, modus ponens gives Q(x). If P(x)→Q(x) and ¬Q(x) are established, modus tollens gives ¬P(x).
Inference Rules with Quantifiers
Universal Instantiation
Universal instantiation allows a specific case to be derived from a universal statement:
Here, c must be an element of the domain. If P(x) is true for every value in the domain, then it is true for any particular value c in that domain.
For example, if the domain is the integers and P(x) means “x+1 is an integer,” then the universal statement permits the conclusion that 23+1 is an integer.
Existential Generalization
Existential generalization allows a universal claim to be made from a verified instance, but only in existential form:
If P(c) is true for some particular c in the domain, then at least one value in the domain makes P(x) true. The conclusion does not claim that every value satisfies the predicate.
For example, if 23+1 is an integer, then there exists an integer x for which x+1 is an integer.
Key Distinctions
A proposition is a complete statement that is true or false; a predicate contains variables and becomes a proposition when those variables are assigned values.
A universal quantifier requires a predicate to hold for every value in the domain; an existential quantifier requires it to hold for at least one value.
An implication p→q is false only when p is true and q is false.
A tautology is always true; a contradiction is always false.
Logical equivalence means that two statements have matching truth values in every possible case.
Modus ponens derives q from p→q and p; modus tollens derives ¬p from p→q and ¬q.
Negating a universal statement produces an existential counterexample, while negating an existential statement produces a universal claim that the predicate never holds.

Ask anything
We've read this whole study set, so questions about it get the best answers.