Module 1 · 17 min read · Free chapter
Propositional and first-order logic
A proposition is true or false. The implication p → q is false only when p is true and q is false, and it equals its contrapositive ¬q → ¬p. Quantifiers flip under negation: ¬∀x P(x) ≡ ∃x ¬P(x). When translating, ∀ goes with → and ∃ goes with ∧.
Start from zero: rules that are either kept or broken
At a railway station the TTE follows a simple rule: "If your ticket is confirmed, then you may board the AC coach." Think of four travellers. One has a confirmed ticket and boards, one has a confirmed ticket and is stopped, one is on the waiting list and boards anyway because a berth fell free, and one is on the waiting list and stays out.
Which traveller shows that the rule was broken? Only the second one, who had a confirmed ticket and was still stopped. The rule says nothing about waiting-list travellers, so whatever happens to them, the rule stands.
This is logic in its plainest form. Each statement here, such as "the ticket is confirmed" or "the traveller boards", is either true or false. Logic gives exact rules for combining such statements and for deciding when a conclusion really follows.
Why it matters. Every if-condition in a program, every database query and every circuit is a logical formula. GATE asks you to check equivalences, decide validity and turn English sentences into formulas, so these rules must be second nature.
Propositions, connectives and truth tables
A proposition is a declarative sentence that is either true or false , but not both. "Delhi is the capital of India" is a proposition, and so is "7 is even", which is simply false. "Close the door" and "" are not propositions, because the first is a command and the second depends on .
We name propositions with letters , , and join them with five connectives. Negation flips the value. Conjunction is true only when both are true, and disjunction is false only when both are false. Implication is false only when is true and is false, and the biconditional is true when both sides have the same value.
| p | q | ||||
|---|---|---|---|---|---|
| T | T | T | T | T | |
| T | F | T | F | F | |
| F | T | T | T | F | |
| F | F | F | T | T |
A truth table lists every combination of input values. With variables there are rows, because each variable doubles the count. Each row can then be marked or in the output column, so the number of different truth functions of variables is . For two variables that is , and for three variables it is .
Worked example. Is always true? The only way to make an implication false is a true left side with a false right side. If is true, then is true, so the right side cannot be false. Hence the formula is true in all four rows.
Why it matters. The truth table is the final judge for any propositional question. When a shortcut fails or you are unsure, eight rows for three variables settle the matter in under a minute.
Implication and its relatives
The implication causes more mistakes than any other connective. It is false in exactly one case: true and false. When is false, the implication is true whatever is, which is called being vacuously true. This matches the TTE rule: a waiting-list traveller can never break a rule about confirmed tickets.
Because the only false case is " and not ", we get the key equivalence . English has many ways to say : "if then ", " if ", " only if ", " is sufficient for " and " is necessary for ". Note especially that " only if " means , not .
From we can build three related statements. The converse is , the inverse is , and the contrapositive is . The contrapositive always has the same truth table as the original, and the converse always matches the inverse.
Worked example. Take "If a number is divisible by 4, then it is even." The contrapositive "If a number is not even, then it is not divisible by 4" is also true. The converse "If a number is even, then it is divisible by 4" is false, since 6 is even but not divisible by 4.
Why it matters. Proof by contrapositive is one of the main proof methods in mathematics. In exams, confusing the converse with the original is the single most common logic error.
Tautologies, equivalences and complete sets
A formula that is true in every row is a tautology, such as . A formula false in every row is a contradiction, such as , and anything in between is a contingency. A formula is satisfiable if at least one row makes it true, so every tautology and every contingency is satisfiable.
There is a neat link between these ideas. A formula is valid (a tautology) exactly when is unsatisfiable. Two formulas A and are logically equivalent, written , when is a tautology, that is when their truth tables match row for row.
A small set of laws lets you simplify formulas without tables:
- De Morgan's laws say that and .
- The distributive laws say that and .
- The absorption laws say that and .
- The biconditional splits as .
- Exportation says that , and proof by cases says that .
Worked example. Show that is a tautology. Suppose it is false; then is false, so and . Then forces , and with forces , which is impossible, so no false row exists.
A set of connectives is functionally complete if every truth function can be written with it alone. The sets , and are complete, and so are the single gates NAND and NOR. The set is not complete, because any formula built only from and is true when all inputs are true, so it can never express .
Why it matters. Equivalences are how compilers simplify conditions and how circuit designers reduce gates. Knowing that NAND alone is complete explains why chips can be built from a single kind of gate, which links straight to Boolean algebra and minimisation.
Normal forms: CNF and DNF
A literal is a variable or its negation, such as or . A formula is in disjunctive normal form (DNF) when it is an OR of terms and each term is an AND of literals, like . It is in conjunctive normal form (CNF) when it is an AND of clauses and each clause is an OR of literals, like .
Every formula can be converted into both forms, and the safe recipe has three steps. First, remove and using . Second, push every inward with De Morgan's laws until it sits on a variable. Third, distribute over for CNF, or over for DNF.
Worked example. Convert into CNF. First , so the formula is , which is already a DNF. Distributing gives , which is the CNF.
There is also a direct way from the truth table. Each row where the formula is true gives a minterm, an AND of all variables with on those that are , and the OR of these minterms is the full DNF. Each false row gives a maxterm, an OR of all variables with on those that are , and the AND of these is the full CNF. So a formula of three variables that is true in 3 rows has 3 minterms and 5 maxterms.
Why it matters. SAT solvers, which check huge circuits and schedules, take input in CNF. The resolution rule of the next section works only on clauses, so CNF is the working format of automated reasoning.
Rules of inference and valid arguments
An argument is a list of premises followed by a conclusion. It is valid when the conclusion must be true whenever all premises are true. In symbols, premises , …, and conclusion form a valid argument exactly when is a tautology.
Instead of building a large table, we chain small valid steps called rules of inference:
| Rule | From | Conclude |
|---|---|---|
| Modus ponens | , | q |
| Modus tollens | , | |
| Hypothetical syllogism | , | |
| Disjunctive syllogism | , | q |
| Resolution | , | |
| Simplification and addition | , and | , and |
Two patterns look like valid rules but are fallacies. Affirming the consequent goes from and to , and denying the antecedent goes from and to . Both fail in the row where is false and is true.
Worked example. Premises: "If it rains, the match is cancelled" , "If the match is cancelled, we go to the cinema" , and "We did not go to the cinema" . Hypothetical syllogism gives , and modus tollens with gives . So the valid conclusion is "It did not rain".
Why it matters. Program verification tools and expert systems chain exactly these rules. In GATE you will be given three or four premises and asked which conclusion follows, and naming the rule for each step is the fastest route.
Predicates and quantifiers
Propositional logic cannot express "every student passed" in a useful way, because it has no way to talk about many objects at once. First-order logic adds predicates and quantifiers. A predicate such as " passed" is neither true nor false until we fix from a domain, here the students of a class.
The universal quantifier says " holds for every in the domain". The existential quantifier says " holds for at least one ". On a finite domain , is a long AND and is a long OR, which is the best way to understand both.
That picture gives the negation rules at once. By De Morgan, and . To negate a formula with several quantifiers, move to the right one step at a time and flip each quantifier it crosses: .
Some quantifier laws are full equivalences and some go one way only:
- , and .
- is valid, but the reverse is not.
- is valid, but the reverse is not.
- is valid, but the reverse is not.
Worked example. Let the domain be integers and be "". is true, since each has . is false, since no single works for every . So swapping and changes the meaning.
Why it matters. Database queries in SQL and relational calculus are first-order formulas over tables. A formula is valid in first-order logic when it is true in every domain and every interpretation, and GATE often asks which of four such formulas is valid.
Translating English into logic
GATE regularly gives an English sentence and four formulas, and asks which formula matches. Four patterns cover almost every case, and the key is which connective goes with which quantifier.
| English | Formula |
|---|---|
| All A are | |
| Some A are | |
| No A is | , same as |
| Not all A are | |
| Only A are |
The rule of thumb is simple: goes with , and goes with . Writing would claim that everything in the domain is an A, which is far too strong. Writing is far too weak, because it becomes true as soon as one object is not an A.
Worked example. Translate "Not every graduate gets a job" with for " is a graduate" and for " gets a job". Start with . Push the negation in: , which reads "some graduate does not get a job".
Sentences with two quantifiers need care about order. "Every student has a friend" is , while "Someone is a friend of every student" is . The second is much stronger, since one person must be a friend of all.
Why it matters. Writing a correct database query or a correct specification is exactly this translation. A wrong connective under a quantifier produces a query that returns the wrong rows without any error message.
Descriptive lens: how written papers ask this
Written papers for scientist posts and university-level tests ask about logic in four ways:
- Prove that a formula is a tautology, either by truth table or by a chain of equivalences.
- Convert a formula into CNF and DNF and state the minterms or maxterms.
- Test an argument for validity using named rules of inference, or show it is a fallacy with a counter-example row.
- Translate English statements into quantified formulas and negate them in simplest form.
Practice questions (our own, not previous-year questions).
- Show without a truth table that . (8 marks)
- Test the validity of this argument: "If the server is up, the site loads. The site does not load. Hence the server is down." Name each rule used. (8 marks)
- Write "Every program that compiles is not necessarily correct" in first-order logic, then negate it and simplify. (10 marks)
Answer plan for question 2.
- Let stand for "the server is up" and for "the site loads", so the premises are and .
- State that the conclusion "the server is down" is .
- Apply modus tollens to and , which gives directly.
- Conclude that the argument is valid, because the conclusion follows by a valid rule.
- Add a check that is true in all four rows of its truth table.
Quick revision
- A proposition is either true or false, and variables give rows and truth functions.
- is false only for and , and it equals .
- An implication equals its contrapositive, and the converse equals the inverse.
- A tautology is always true, a contradiction is always false, and is valid exactly when is unsatisfiable.
- NAND alone and NOR alone are functionally complete, but is not.
- Full DNF takes one minterm per true row, and full CNF takes one maxterm per false row.
- Modus ponens, modus tollens, hypothetical syllogism, disjunctive syllogism and resolution are valid rules.
- , and .
- goes with and goes with when translating English.
- implies , but not the other way round.