3 Logic And Proof Methods

Discrete Structures · Unit 3 · 6 hrs

Logic and Proof Methods

Exam-focused notes for Logic and Proof Methods (Discrete Structures, CSC165): what the TU syllabus asks and how it has actually been tested, with 14 solved past questions from this unit.

Logic and Proof Methods in short

This chapter develops mathematical logic, the formal language for reasoning that underlies circuit design, program verification and every proof written afterward: propositions and their connectives, quantified statements over predicates, valid rules of inference, and the standard techniques for writing a correct proof.

Logic and Proof Methods: notes

Logic

Logic is the language of reasoning: it fixes a small set of connectives and rules so that an argument's validity can be checked mechanically, independent of the specific claim being argued. Applications in computer science range from designing digital circuits to verifying that a program meets its specification.

Propositional Logic

A proposition is a declarative sentence that is either true or false, but never both, for example "Kathmandu is the capital of Nepal" (true) or "$2+2=5$" (false); a command such as "come here" or an open sentence such as "$x>5$" is not a proposition, since it has no fixed truth value on its own. Propositions are denoted by lower-case letters $p,q,r,\ldots$ and their truth value by $T$ or $F$. Propositions are combined into compound propositions using logical connectives, whose behaviour is captured completely by a truth table listing every combination of the component truth values.

The basic connectives are:

  • Negation ($\neg p$, "not $p$"): true exactly when $p$ is false.
  • Conjunction ($p \land q$, "$p$ and $q$"): true only when both $p$ and $q$ are true.
  • Disjunction ($p \lor q$, "$p$ or $q$"): false only when both $p$ and $q$ are false.
  • Conditional ($p \rightarrow q$, "if $p$ then $q$"): false only when $p$ is true and $q$ is false.
  • Biconditional ($p \leftrightarrow q$, "$p$ if and only if $q$"): true exactly when $p$ and $q$ share the same truth value.
$p$$q$$\neg p$$p \land q$$p \lor q$$p \rightarrow q$$p \leftrightarrow q$
TTFTTTT
TFFFTFF
FTTFTTF
FFTFFTT

The conditional $p \rightarrow q$ has three related statements built from the same $p$ and $q$: its converse $q \rightarrow p$, its inverse $\neg p \rightarrow \neg q$, and its contrapositive $\neg q \rightarrow \neg p$. The contrapositive is logically equivalent to the original conditional (both are true in exactly the same rows of the truth table), while the converse and inverse are equivalent to each other but not, in general, to the original. For "if today is Sunday, it is hot": the converse is "it is hot only if today is Sunday", the inverse is "if today is not Sunday, it is not hot", and the contrapositive, "if it is not hot today, it is not Sunday", carries the same truth value as the original statement in every case.

Constructing a truth table for a more complex expression such as $\neg p \land (p \lor \neg q)$ requires a column for every sub-expression, building up from the innermost connectives outward, so that each row can be checked mechanically without guessing the final value.

A compound proposition that is true in every row of its truth table, regardless of the truth values of its components, is a tautology; one that is false in every row is a contradiction; one that is neither, so its truth value genuinely depends on the components, is a contingency.

Propositional Equivalences

Two compound propositions $p$ and $q$ are logically equivalent, written $p \equiv q$, if they have identical truth tables, equivalently if $p \leftrightarrow q$ is a tautology. The standard equivalences, all provable by truth table, are:

LawForm
Identity$p \land T \equiv p$, $\ p \lor F \equiv p$
Domination$p \lor T \equiv T$, $\ p \land F \equiv F$
Idempotent$p \lor p \equiv p$, $\ p \land p \equiv p$
Double negation$\neg(\neg p) \equiv p$
Commutative$p \lor q \equiv q \lor p$, $\ p \land q \equiv q \land p$
Associative$(p\lor q)\lor r \equiv p\lor(q\lor r)$, similarly for $\land$
Distributive$p\lor(q\land r) \equiv (p\lor q)\land(p\lor r)$, and dually for $\land$ over $\lor$
De Morgan's$\neg(p\land q)\equiv \neg p \lor \neg q$, $\ \neg(p\lor q)\equiv \neg p \land \neg q$
Absorption$p \lor (p\land q) \equiv p$, $\ p \land (p\lor q)\equiv p$
Negation$p \lor \neg p \equiv T$, $\ p \land \neg p \equiv F$
Conditional as disjunction$p \rightarrow q \equiv \neg p \lor q$
Contrapositive$p \rightarrow q \equiv \neg q \rightarrow \neg p$
Biconditional$p \leftrightarrow q \equiv (p\rightarrow q)\land(q\rightarrow p)$

A useful shortcut once these are memorised is proving an equivalence symbolically, by rewriting one side into the other using the laws step by step, rather than expanding a full truth table every time. Every compound proposition also has a dual: the statement obtained by swapping every $\lor$ with $\land$ (and vice versa) and every $T$ with $F$; De Morgan's laws are exactly dual pairs of each other.

What this unit covers

  • Logic
  • Propositional Logic
  • Propositional Equivalences
  • Predicates and Quantifiers
  • Negation of Quantified Statements
  • Proof of quantified statements
  • Nested Quantifiers
  • Rules of Inferences
  • Proof Methods
  • Basic Terminologies
  • Proof Methods (Direct Proof, Indirect Proof, Proof by Contradiction, Proof By Contraposition, Exhaustive Proofs and Proof by Cases)
  • Mistakes in Proof

Rules of Inferences

2081 · 10 marks

List any four rules of inference. Using direct and indirect proof show that, for any real number $x$, if $x^3 - 7x^2 + x - 7 = 0$, then $x = 7$ [10]

Show solved answer

Rules of Inference and Proof Techniques

Part 1: Four Rules of Inference

Rule of InferenceFormName
1p, p→q ∴ qModus Ponens
2¬q, p→q ∴ ¬pModus Tollens
3p→q, q→r ∴ p→rHypothetical Syllogism
4p∨q, ¬p ∴ qDisjunctive Syllogism

Part 2: Proof of the Statement

Theorem: For any real number x, if x³ - 7x² + x - 7 = 0, then x = 7.

Note: The converse of this statement is NOT true in general (x = 7 gives 343 - 343 + 7 - 7 = 0 ✓, but x = i and x = -i also satisfy the equation). The correct interpretation for this exam is to prove: if x is a real number satisfying x³ - 7x² + x - 7 = 0, then x = 7 (since the other roots i and -i are not real).

Let:

  • p: x³ - 7x² + x - 7 = 0
  • q: x = 7

Method 1: Direct Proof (Proving p → q)

Assume p is true, i.e., assume:

$$x^3 - 7x^2 + x - 7 = 0$$

Step 1: Factor the left-hand side by grouping:

$$x^3 - 7x^2 + x - 7 = 0$$

$$x^2(x - 7) + 1(x - 7) = 0$$

Step 2: Factor out the common term (x - 7):

$$(x^2 + 1)(x - 7) = 0$$

Step 3: Apply the Zero Product Property. Either:

$$x^2 + 1 = 0 \quad \text{or} \quad x - 7 = 0$$

Step 4: Analyze each case:

  • From x² + 1 = 0: x² = -1, which has no real solution (since x² ≥ 0 for all real x).
  • From x - 7 = 0: x = 7 ✓

Step 5: Since x is a real number, the only valid solution is x = 7.

Therefore, if x³ - 7x² + x - 7 = 0, then x = 7. [Direct Proof Complete] ∎


Method 2: Indirect Proof (Proof by Contradiction, Proving p → q)

In indirect proof, we assume p is true and q is false, and derive a contradiction.

Assume:

  • p is true: x³ - 7x² + x - 7 = 0
  • q is false: x ≠ 7 (i.e., x is a real number and x ≠ 7)

Step 1: Factor the equation as before:

$$x^3 - 7x^2 + x - 7 = 0$$

$$x^2(x - 7) + 1(x - 7) = 0$$

$$(x^2 + 1)(x - 7) = 0$$

Step 2: Since we assumed x ≠ 7, we have (x - 7) ≠ 0.

Therefore, for the product to equal zero, we must have:

$$x^2 + 1 = 0$$

$$x^2 = -1$$

Step 3: But x is a real number, so x² ≥ 0 for all real x.

This means x² = -1 is impossible for any real number x.

Step 4: This is a contradiction -- we assumed x is real but arrived at x² = -1, which has no real solution.

Step 5: Therefore, our assumption that x ≠ 7 must be false.

Hence, x = 7 must be true.

[Indirect Proof Complete] ∎


Summary

MethodApproachConclusion
Direct ProofAssume p, derive q through factoringx = 7 follows directly
Indirect ProofAssume p and ¬q, derive contradiction¬q leads to x² = -1, impossible for real x

Both methods confirm: For any real number x, if x³ - 7x² + x - 7 = 0, then x = 7.

Open this answer on its own page →

2079 · 5 marks

Give the premise 'If it rains or strike holds then the exam will be cancelled. If it doesn't rain then it will be sunny day. The exam was not cancelled. Show that it was sunny day'. [5]

Let us define the propositional variables: - p : It rains - q : Strike holds - r : Exam will be cancelled - s : It will be a sunny day --- No. Premise Symbolic Form ----------------------------- P1 If it rains or strike holds, then exam will be cancelled (p ∨ q) → r P2 If it doesn't rain, then it...

Open this answer on its own page →

2078 · 5 marks

Define proposition. Consider the argument 'John, a student in this class knows how to write program in C. Everyone who knows how to write program in C can get a high paying job. Therefore, someone in this class can get high paying job'. Now, explain which rules of inferences are used for each step. [5]

A proposition is a declarative statement that is either true or false, but not both. It has a definite truth value (T or F). Examples: - "The sky is blue." (True proposition) - "2 + 2 = 5." (False proposition) - "What time is it?" (NOT a proposition, it is a question) --- 1. "John, a student in t...

Open this answer on its own page →

Predicates and Quantifiers

2080 · 5 marks

Express the following sentences using quantifier. 1) Not all people are loyal. 2)Everybody loves somebody. 3). Someone has passed the exam 4). Aquatic animals can't live without water 5). Some subjects are not interesting. [5]

Definitions used: Let the domain of discourse be the set of all people/subjects/animals unless stated otherwise. --- Let L(x) = "x is loyal" Logical Expression: $$\neg \forall x ; L(x)$$ This is equivalent to: $$\exists x ; \neg L(x)$$ "There exists at least one person who is not loyal." --- Le...

Open this answer on its own page →

2079 · 5 marks

List any one example of tautology. Represent the following sentences into predicate logic. a. Not all employees are loyal. b. All students having good attitude are lovable. [5]

A tautology is a propositional formula that is always true regardless of the truth values of its variables. Example: $$P \lor \neg P \quad \text{(Law of Excluded Middle)}$$ P ¬P P ∨ ¬P ---------------- T F T F T T Since the formula is true in all cases, it is a tautology. --- - Let the domain be ...

Open this answer on its own page →

2078 · 10 marks

State division and remainder algorithm. Suppose that the domain of the propositional function P(x) consists of the integer 0, 1, 2, 3 and 4. Write out each of the following propositions using disjunctions, conjunctions and negations. a. ∃x P(x)b. ∀x P(x)c. ∃x ¬P(x)d. ∀x ¬P(x)e. ¬∃x P(x)f. ¬∀x P(x)\text{a. } \exists x , P(x) \quad \text{b. } \forall x , P(x) \quad \text{c. } \exists x , \neg P(x) \quad \text{d. } \forall x , \neg P(x) \quad \text{e. } \neg \exists x , P(x) \quad \text{f. } \neg \forall x , P(x)a. ∃xP(x)b. ∀xP(x)c. ∃x¬P(x)d. ∀x¬P(x)e. ¬∃xP(x)f. ¬∀xP(x)[10]

Show solved answer

Division and Remainder Algorithm + Quantifier Expansion

Part 1: Division and Remainder Algorithm (The Division Algorithm)

Statement

Division Algorithm: Let a be an integer and d a positive integer. Then there exist unique integers q and r with 0 ≤ r < d such that:

a = d·q + r

Where:

  • d is called the divisor
  • a is called the dividend
  • q is called the quotient → written as q = a div d
  • r is called the remainder → written as r = a mod d

Procedure (div-mod algorithm from notes)

procedure div-mod(a ∈ Z, d ∈ Z⁺)
  q := 0
  r := |a|
  while r ≥ d begin
    r := r - d
    q := q + 1
  end
  if a < 0 and r > 0 then
    q := -(q + 1)
    r := d - r
  return q, r

Working principle: When a is positive, we subtract d from a repeatedly until what remains is less than d. The number of subtractions performed is the quotient q, and what remains is the remainder r.

Example

What is the quotient and remainder when 101 is divided by 11?

101 = 11 × 9 + 2

So: q = 101 div 11 = 9 and r = 101 mod 11 = 2


Part 2: Expanding Quantified Propositions

Given: Domain of P(x) = {0, 1, 2, 3, 4}

The key rules used are:

QuantifierExpansion Rule
∃x P(x)P(0) ∨ P(1) ∨ P(2) ∨ P(3) ∨ P(4)
∀x P(x)P(0) ∧ P(1) ∧ P(2) ∧ P(3) ∧ P(4)

a. ∃x P(x)

"There exists at least one x in the domain such that P(x) is true."

$$\exists x, P(x) \equiv P(0) \lor P(1) \lor P(2) \lor P(3) \lor P(4)$$


b. ∀x P(x)

"P(x) is true for every x in the domain."

$$\forall x, P(x) \equiv P(0) \land P(1) \land P(2) \land P(3) \land P(4)$$


c. ∃x ¬P(x)

"There exists at least one x for which P(x) is false."

$$\exists x, \neg P(x) \equiv \neg P(0) \lor \neg P(1) \lor \neg P(2) \lor \neg P(3) \lor \neg P(4)$$


d. ∀x ¬P(x)

"P(x) is false for every x in the domain."

$$\forall x, \neg P(x) \equiv \neg P(0) \land \neg P(1) \land \neg P(2) \land \neg P(3) \land \neg P(4)$$


e. ¬∃x P(x)

"There is no x for which P(x) is true."

By De Morgan's Law for quantifiers: ¬∃x P(x) ≡ ∀x ¬P(x)

$$\neg \exists x, P(x) \equiv \neg P(0) \land \neg P(1) \land \neg P(2) \land \neg P(3) \land \neg P(4)$$

Note: This is logically equivalent to part (d).


f. ¬∀x P(x)

"It is not the case that P(x) is true for all x."

By De Morgan's Law for quantifiers: ¬∀x P(x) ≡ ∃x ¬P(x)

$$\neg \forall x, P(x) \equiv \neg P(0) \lor \neg P(1) \lor \neg P(2) \lor \neg P(3) \lor \neg P(4)$$

Note: This is logically equivalent to part (c).


Summary Table

PropositionExpanded Form
∃x P(x)P(0) ∨ P(1) ∨ P(2) ∨ P(3) ∨ P(4)
∀x P(x)P(0) ∧ P(1) ∧ P(2) ∧ P(3) ∧ P(4)
∃x ¬P(x)¬P(0) ∨ ¬P(1) ∨ ¬P(2) ∨ ¬P(3) ∨ ¬P(4)
∀x ¬P(x)¬P(0) ∧ ¬P(1) ∧ ¬P(2) ∧ ¬P(3) ∧ ¬P(4)
¬∃x P(x)¬P(0) ∧ ¬P(1) ∧ ¬P(2) ∧ ¬P(3) ∧ ¬P(4)
¬∀x P(x)¬P(0) ∨ ¬P(1) ∨ ¬P(2) ∨ ¬P(3) ∨ ¬P(4)

Conclusion

Over a finite domain a quantifier is only a compact way of writing a long connective: the existential quantifier unfolds into a disjunction and the universal quantifier unfolds into a conjunction, one term for each element of the domain. The two De Morgan laws for quantifiers, $\neg \exists x, P(x) \equiv \forall x, \neg P(x)$ and $\neg \forall x, P(x) \equiv \exists x, \neg P(x)$, are visible directly in the table above, since (e) matches (d) and (f) matches (c). The division algorithm plays the same role for integers: it guarantees that for any integer $a$ and any positive divisor $d$ the pair $(q, r)$ with $a = dq + r$ and $0 \le r < d$ exists and is unique, which is what makes div and mod well defined operations.

Open this answer on its own page →

Proof Methods

2080 · 5 marks

What is proof by contradiction? Give a proof by contradiction to show that if 3n+2 is odd then n is odd. [5]

Show solved answer

Proof by Contradiction

Definition

Proof by contradiction is a method of mathematical proof in which we assume that the statement to be proved is false, and then show that this assumption leads to a logical contradiction (an impossibility). Since the assumption leads to a contradiction, the original statement must be true.

The general structure is:

  1. Assume the negation of what we want to prove.
  2. Use logical reasoning to derive a contradiction.
  3. Conclude that the original statement is true.

Theorem to Prove

If 3n + 2 is odd, then n is odd.


Proof

Step 1: Identify the structure

  • Hypothesis (p): 3n + 2 is odd
  • Conclusion (q): n is odd
  • We want to prove: p → q

Step 2: Assume the negation of the conclusion

For proof by contradiction, we assume:

  • 3n + 2 is odd (hypothesis holds)
  • n is NOT odd, i.e., n is even (negation of conclusion)

Step 3: Use the assumption

Since n is even, by definition of even integers, we can write:

$$n = 2k \quad \text{for some integer } k$$

Step 4: Substitute into 3n + 2

$$3n + 2 = 3(2k) + 2 = 6k + 2 = 2(3k + 1)$$

Step 5: Analyze the result

Since $3k + 1$ is an integer, the expression $2(3k + 1)$ is of the form $2m$ where $m = 3k + 1$.

By definition of even numbers, $3n + 2$ is even.

Step 6: Identify the contradiction

We assumed that 3n + 2 is odd, but our derivation shows that 3n + 2 is even.

This is a contradiction because a number cannot be both odd and even at the same time.

Step 7: Conclusion

Since assuming "n is even" leads to a contradiction, our assumption must be false. Therefore:

$$\boxed{n \text{ is odd}}$$

This completes the proof by contradiction. $\blacksquare$

Open this answer on its own page →

2079 · 5 marks

Prove that 'If the product of two integers a and b is even then either a is even or b is even' using condition method. [5]

The conditional method (also called proof by contrapositive) proves a statement of the form: P → Q by instead proving its contrapositive: ¬Q → ¬P which is logically equivalent to the original statement. --- Original Statement: If a × b is even, then a is even or b is even. Let us define: - P: a ×...

Open this answer on its own page →

2078 · 5 marks

Prove that if n is positive integer, then n is odd if and only if 5n + 6 is odd. [5]

We must prove a biconditional statement: n is odd $\iff$ 5n + 6 is odd A biconditional proof requires proving both directions: 1. (Forward) If n is odd, then 5n + 6 is odd. 2. (Backward) If 5n + 6 is odd, then n is odd. We use the standard definitions: - An integer k is odd if there exists an int...

Open this answer on its own page →

2075 · 5 marks

Prove that the product xy is odd if and only if both x and y are odd integers. [5]

Claim: For integers x and y, the product xy is odd if and only if both x and y are odd. --- From the course notes on Integer and Division: - An integer b is odd if it cannot be written as b = 2k for any integer k; equivalently, b = 2k + 1 for some integer k. - An integer b is even if b = 2k for s...

Open this answer on its own page →

2080.1 · 5 marks

What is direct proof? Give a direct proof that if m and n are both perfect squares, then mn is also a perfect square. [5]

Show solved answer

Direct Proof: Product of Two Perfect Squares is a Perfect Square

Definition: Direct Proof

A direct proof is a method of proving a statement of the form "if P then Q" by assuming that P is true and then, using definitions, axioms, theorems, and logical reasoning step by step, showing that Q must also be true.

In other words, we start from the hypothesis and proceed forward through a chain of logical deductions until we reach the conclusion.


Definition: Perfect Square

An integer $n$ is called a perfect square if there exists an integer $k$ such that: $$n = k^2$$

Examples: $1, 4, 9, 16, 25, \ldots$ are perfect squares.


Theorem

If $m$ and $n$ are both perfect squares, then $mn$ is also a perfect square.


Direct Proof

Assume (hypothesis) that $m$ and $n$ are both perfect squares.

Step 1: Since $m$ is a perfect square, by definition there exists an integer $a$ such that: $$m = a^2$$

Step 2: Since $n$ is a perfect square, by definition there exists an integer $b$ such that: $$n = b^2$$

Step 3: Compute the product $mn$: $$mn = a^2 \cdot b^2$$

Step 4: Using the properties of exponents and multiplication: $$mn = a^2 \cdot b^2 = (ab)^2$$

Step 5: Let $c = ab$. Since $a$ and $b$ are integers, their product $c = ab$ is also an integer.

Step 6: Therefore: $$mn = c^2$$

where $c$ is an integer.

Conclusion: By the definition of a perfect square, $mn$ is a perfect square. $\blacksquare$


Summary Table

StepStatementReason
1$m = a^2$ for some integer $a$$m$ is a perfect square (hypothesis)
2$n = b^2$ for some integer $b$$n$ is a perfect square (hypothesis)
3$mn = a^2 b^2$Substitution
4$mn = (ab)^2$Laws of exponents
5Let $c = ab \in \mathbb{Z}$Product of integers is an integer
6$mn = c^2$Definition of perfect square satisfied
Open this answer on its own page →

Nested Quantifiers

2076 · 5 marks

All over smart people are stupid. Children of stupid people are naughty. John is a children of Jane. Jane is over smart. Represent these statements in FOPL and prove that John is naughty. [5]

English Statement FOPL Representation ------ All over smart people are stupid. ∀x: OverSmart(x) → Stupid(x) Children of stupid people are naughty. ∀x ∀y: Stupid(x) ∧ ChildOf(y, x) → Naughty(y) John is a child of Jane. ChildOf(John, Jane) Jane is over smart. OverSmart(Jane) --- Given Facts and Rul...

Open this answer on its own page →

Propositional Logic

2075 · 5 marks

Let A = 'Aldo is Italian' and B = 'Bob is English'. Formalize the following sentences into proposition.a. Aldo isn't Italian.b. Aldo is Italian while Bob is English.c. If Aldo is Italian then Bob is not English.d. Aldo is Italian or if Aldo isn't Italian then Bob is English.e. Either Aldo is Italian and Bob is English, or neither Aldo is Italian nor is Bob English. [5]

Let: - A = 'Aldo is Italian' - B = 'Bob is English' --- This is the negation of A. $$\neg A$$ --- The word "while" expresses that both statements hold simultaneously, so this is a conjunction. $$A \land B$$ --- This is a conditional (implication) where the consequent contains a negation. $$A \rig...

Open this answer on its own page →

Propositional Equivalences

2080.1 · 5 marks

Give an example of tautology and contradiction. Show that implication and contrapositive are equivalence. [5]

--- A tautology is a compound proposition that is always true, regardless of the truth values of its component propositions. Example: $$p \lor \neg p \quad \text{("p or not p")}$$ $p$ $\neg p$ $p \lor \neg p$ -------------------------------- T F T F T T Since the last column is always T,

Open this answer on its own page →