1. Home
  2. Explore
  3. Mathematics
  4. Discrete Mathematics: Logic and Proofs

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

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 ppp, qqq, or rrr, stand for propositions. For example:

  • Let ppp mean “Delhi is the capital of India.”

  • Let qqq 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\neg p¬p, read “not ppp.” It reverses the truth value of ppp.

  • Conjunction: p∧qp \land qp∧q, read “ppp and qqq.” It is true only when both propositions are true.

  • Disjunction: p∨qp \lor qp∨q, read “ppp or qqq.” In propositional logic, “or” is normally inclusive: it is true when at least one proposition is true, including when both are true.

  • Implication: p→qp \to qp→q, read “if ppp, then qqq.”

  • Equivalence: p↔qp \leftrightarrow qp↔q, read “ppp if and only if qqq.” It is true when ppp and qqq have the same truth value.

A connective may combine propositions into a compound proposition. For example, if ppp and qqq are the propositions above, then p∧qp \land qp∧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, ppp and qqq, there are four possible combinations. With one proposition, there are two. In general, a truth table for nnn variables has 2n2^n2n rows.

Negation

Negation reverses the truth value of its proposition:

  • If ppp is true, then ¬p\neg p¬p is false.

  • If ppp is false, then ¬p\neg p¬p is true.

Conjunction

The conjunction p∧qp \land qp∧q is true only when both ppp and qqq are true. If either proposition is false, the conjunction is false.

Disjunction

The disjunction p∨qp \lor qp∨q is true when at least one of ppp and qqq is true. It is false only when both are false.

Implication

The implication p→qp \to qp→q is false only when ppp is true and qqq is false. In every other case, it is true.

The proposition ppp is called the antecedent and qqq the consequent. The meaning of implication can be summarized as follows:

  • When ppp is true, qqq must also be true for the implication to hold.

  • When ppp is false, the implication is considered true, regardless of whether qqq is true or false.

Thus, p→qp \to qp→q does not assert that ppp or qqq is true by itself. It asserts that a true ppp cannot be paired with a false qqq.

Equivalence

The equivalence p↔qp \leftrightarrow qp↔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:

p↔q≡(p→q)∧(q→p)p \leftrightarrow q \equiv (p \to q) \land (q \to p)p↔q≡(p→q)∧(q→p)

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↔qp \leftrightarrow qp↔q with (p→q)∧(q→p)(p \to q) \land (q \to p)(p→q)∧(q→p):

  1. Create columns for ppp and qqq and list their possible truth values.

  2. Evaluate p→qp \to qp→q.

  3. Evaluate q→pq \to pq→p.

  4. Combine those results using ∧\land∧.

  5. Compare the resulting column with the column for p↔qp \leftrightarrow qp↔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:

p∧q≡q∧pp \land q \equiv q \land pp∧q≡q∧p
p∨q≡q∨pp \lor q \equiv q \lor pp∨q≡q∨p

Other useful equivalences include the De Morgan laws:

¬(p∧q)≡¬p∨¬q\neg(p \land q) \equiv \neg p \lor \neg q¬(p∧q)≡¬p∨¬q
¬(p∨q)≡¬p∧¬q\neg(p \lor q) \equiv \neg p \land \neg q¬(p∨q)≡¬p∧¬q

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)P(x)P(x) mean “xxx is a student.” The expression P(x)P(x)P(x) is not yet a complete proposition because the value of xxx has not been specified.

Substituting a particular value produces a proposition:

  • P(a)P(a)P(a) means “aaa is a student.”

  • P(b)P(b)P(b) means “bbb is a student.”

A predicate can have multiple variables. For example, let Q(x,y)Q(x,y)Q(x,y) mean “x+y=3x+y=3x+y=3.” Assigning values to both variables makes it a proposition, such as Q(1,2)Q(1,2)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)P(x)P(x) means “xxx is a student,” the domain might be a set of people.

  • If Q(x)Q(x)Q(x) concerns whether xxx 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 ∀\forall∀, means “for all” or “for every.”

∀x P(x)\forall x\, P(x)∀xP(x)

This says that P(x)P(x)P(x) is true for every value of xxx in the domain.

For example, if the domain is the integers and P(x)P(x)P(x) means “x+1x+1x+1 is an integer,” then ∀x P(x)\forall x\,P(x)∀xP(x) is true.

Existential quantifier

The existential quantifier, written ∃\exists∃, means “there exists at least one.”

∃x P(x)\exists x\, P(x)∃xP(x)

This says that at least one value of xxx in the domain makes P(x)P(x)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,

R(x)∧Q(y)R(x) \land Q(y)R(x)∧Q(y)

is true for assigned values of xxx and yyy when both R(x)R(x)R(x) and Q(y)Q(y)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:

∀x (R(x)∧Q(y))\forall x\,\bigl(R(x) \land Q(y)\bigr)∀x(R(x)∧Q(y))

Here, the quantifier ∀x\forall x∀x governs the expression inside the parentheses. It does not quantify over yyy; yyy 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:

¬(∀x P(x))≡∃x ¬P(x)\neg(\forall x\,P(x)) \equiv \exists x\,\neg P(x)¬(∀xP(x))≡∃x¬P(x)

The negation of “P(x)P(x)P(x) holds for every xxx” means “there is at least one xxx for which P(x)P(x)P(x) does not hold.”

Similarly,

¬(∃x P(x))≡∀x ¬P(x)\neg(\exists x\,P(x)) \equiv \forall x\,\neg P(x)¬(∃xP(x))≡∀x¬P(x)

The negation of “there exists an xxx for which P(x)P(x)P(x) holds” means “for every xxx, P(x)P(x)P(x) does not hold.”

For instance, if the domain is the integers and P(x)P(x)P(x) means “xxx 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:

¬(A∧B)≡¬A∨¬B\neg(A \land B) \equiv \neg A \lor \neg B¬(A∧B)≡¬A∨¬B
¬(A∨B)≡¬A∧¬B\neg(A \lor B) \equiv \neg A \land \neg B¬(A∨B)≡¬A∧¬B

Here, AAA and BBB 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,

pqp∧q\frac{p \qquad q}{p \land q}p∧qpq​

means that if both ppp and qqq are true, then p∧qp \land qp∧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 ppp and qqq are true, their conjunction is true:

pqp∧q\frac{p \qquad q}{p \land q}p∧qpq​

Simplification

If p∧qp \land qp∧q is true, then each component is true. In particular:

p∧qp\frac{p \land q}{p}pp∧q​

The same reasoning permits the conclusion qqq.

Addition

If ppp is true, then p∨qp \lor qp∨q is true, regardless of the truth value of qqq:

pp∨q\frac{p}{p \lor q}p∨qp​

Modus ponens

Modus ponens applies an implication to its antecedent:

p→qpq\frac{p \to q \qquad p}{q}qp→qp​

If p→qp \to qp→q is true and ppp is true, then qqq 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 222,” and a particular number is even, then that number is divisible by 222.

Modus tollens

Modus tollens uses the negation of an implication’s consequent to infer the negation of its antecedent:

p→q¬q¬p\frac{p \to q \qquad \neg q}{\neg p}¬pp→q¬q​

If ppp would imply qqq, but qqq is false, then ppp 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:

p∨qp\frac{p \lor q}{p}pp∨q​

A disjunction can be true because qqq is true even when ppp is false. For instance, if ppp is false and qqq is true, then p∨qp \lor qp∨q is true but ppp 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)P(x)P(x) means “xxx is even.”

  • Q(x)Q(x)Q(x) means “xxx is divisible by 222.”

If P(x)→Q(x)P(x) \to Q(x)P(x)→Q(x) and P(x)P(x)P(x) are both established, modus ponens gives Q(x)Q(x)Q(x). If P(x)→Q(x)P(x) \to Q(x)P(x)→Q(x) and ¬Q(x)\neg Q(x)¬Q(x) are established, modus tollens gives ¬P(x)\neg P(x)¬P(x).


Inference Rules with Quantifiers

Universal Instantiation

Universal instantiation allows a specific case to be derived from a universal statement:

∀x P(x)P(c)\frac{\forall x\,P(x)}{P(c)}P(c)∀xP(x)​

Here, ccc must be an element of the domain. If P(x)P(x)P(x) is true for every value in the domain, then it is true for any particular value ccc in that domain.

For example, if the domain is the integers and P(x)P(x)P(x) means “x+1x+1x+1 is an integer,” then the universal statement permits the conclusion that 23+123+123+1 is an integer.

Existential Generalization

Existential generalization allows a universal claim to be made from a verified instance, but only in existential form:

P(c)∃x P(x)\frac{P(c)}{\exists x\,P(x)}∃xP(x)P(c)​

If P(c)P(c)P(c) is true for some particular ccc in the domain, then at least one value in the domain makes P(x)P(x)P(x) true. The conclusion does not claim that every value satisfies the predicate.

For example, if 23+123+123+1 is an integer, then there exists an integer xxx for which x+1x+1x+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→qp \to qp→q is false only when ppp is true and qqq 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 qqq from p→qp \to qp→q and ppp; modus tollens derives ¬p\neg p¬p from p→qp \to qp→q and ¬q\neg q¬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.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent