सभी नोट्स

Logic: propositional and predicate

गेट DA210 मिनट में पढ़ें

मुफ़्त प्रीव्यू: नोट का 26%

Propositional logic

Definition. A proposition is a statement that is either true or false. Formulas are built from propositional variables p,q,r,…p, q, r, \dots with the connectives ¬\neg (not), ∧\wedge (and), ∨\vee (or), →\rightarrow (implies) and ↔\leftrightarrow (if and only if).

Implication. p→qp \rightarrow q is false only when pp is true and qq is false. So it is equivalent to ¬p∨q\neg p \vee q. Its contrapositive ¬q→¬p\neg q \rightarrow \neg p is equivalent to it; its converse q→pq \rightarrow p and inverse ¬p→¬q\neg p \rightarrow \neg q are not.

ppqqp∧qp \wedge qp∨qp \vee qp→qp \rightarrow qp↔qp \leftrightarrow q
TTTTTT
TFFTFF
FTFTTF
FFFFTT

Useful equivalences.

  • De Morgan: ¬(p∧q)≡¬p∨¬q\neg(p \wedge q) \equiv \neg p \vee \neg q and ¬(p∨q)≡¬p∧¬q\neg(p \vee q) \equiv \neg p \wedge \neg q.
  • Distribution: p∨(q∧r)≡(p∨q)∧(p∨r)p \vee (q \wedge r) \equiv (p \vee q) \wedge (p \vee r).
  • p↔q≡(p→q)∧(q→p)p \leftrightarrow q \equiv (p \rightarrow q) \wedge (q \rightarrow p).
  • Exportation: (p∧q)→r≡p→(q→r)(p \wedge q) \rightarrow r \equiv p \rightarrow (q \rightarrow r).

Kinds of formula. A tautology is true under every assignment (e.g. p∨¬pp \vee \neg p); a contradiction is false under every assignment; a formula is satisfiable if at least one assignment makes it true. A formula α\alpha is valid exactly when ¬α\neg\alpha is unsatisfiable.

Entailment. A knowledge base KBKB entails α\alpha, written KB⊨αKB \models \alpha, if α\alpha is true in every model (assignment) where KBKB is true. Equivalently, KB∧¬αKB \wedge \neg\alpha is unsatisfiable. A formula over nn variables has 2n2^n assignments, so model checking by truth table takes O(2n)O(2^n) time.

Solved examples

Example 1: is it a tautology? Check ((p→q)∧p)→q((p \rightarrow q) \wedge p) \rightarrow q (modus ponens). The only way an implication fails is a true premise with a false conclusion: qq false and (p→q)∧p(p \rightarrow q) \wedge p true. But pp true and qq false make p→qp \rightarrow q false. So it never fails: a tautology.

Example 2: equivalent forms. ¬(p→q)≡¬(¬p∨q)≡p∧¬q\neg(p \rightarrow q) \equiv \neg(\neg p \vee q) \equiv p \wedge \neg q.

Inference rules and resolution

Sound rules derive only entailed conclusions:

  • Modus ponens: from p→qp \rightarrow q and pp, infer qq.
  • Modus tollens: from p→qp \rightarrow q and ¬q\neg q, infer ¬p\neg p.
  • Hypothetical syllogism: from p→qp \rightarrow q and q→rq \rightarrow r, infer p→rp \rightarrow r.
  • Disjunctive syllogism: from p∨qp \vee q and ¬p\neg p, infer qq.

Fallacies (not valid): affirming the consequent (p→qp \rightarrow q, qq, so pp) and denying the antecedent (p→qp \rightarrow q, ¬p\neg p, so ¬q\neg q).

Conjunctive normal form (CNF): a conjunction of clauses, each a disjunction of literals. Every formula has an equivalent CNF: remove ↔\leftrightarrow and →\rightarrow, push ¬\neg inward with De Morgan, then distribute ∨\vee over ∧\wedge.

Resolution: from clauses (A∨x)(A \vee x) and (B∨¬x)(B \vee \neg x) infer (A∨B)(A \vee B). To prove KB⊨αKB \models \alpha: convert KB∧¬αKB \wedge \neg\alpha to CNF and resolve repeatedly; deriving the empty clause proves entailment (refutation). Resolution is sound and refutation-complete.

Horn clauses have at most one positive literal, e.g. ¬p∨¬q∨r\neg p \vee \neg q \vee r, i.e. p∧q→rp \wedge q \rightarrow r. For Horn knowledge bases, forward chaining (fire rules whose premises are known) and backward chaining (work back from the goal) decide entailment in time linear in the size of the KB.

Solved example

Example 3: resolution proof. KB: p→qp \rightarrow q, q→rq \rightarrow r, pp. Goal: rr.

  1. Clauses: (¬p∨q)(\neg p \vee q), (¬q∨r)(\neg q \vee r), (p)(p), and the negated goal (¬r)(\neg r).
  2. Resolve (¬q∨r)(\neg q \vee r) with (¬r)(\neg r): (¬q)(\neg q).
  3. Resolve (¬p∨q)(\neg p \vee q) with (¬q)(\neg q): (¬p)(\neg p).
  4. Resolve (¬p)(\neg p) with (p)(p): the empty clause.

So KB⊨rKB \models r.

Predicate (first-order) logic

Definition. First-order logic adds objects, predicates (properties and relations, such as Student(x)\text{Student}(x) or Likes(x,y)\text{Likes}(x,y)), functions, and the quantifiers ∀\forall (for all) and ∃\exists (there exists).

Translating English.

  • "All students study": ∀x (Student(x)→Studies(x))\forall x\, (\text{Student}(x) \rightarrow \text{Studies}(x)). Use →\rightarrow with ∀\forall.
  • "Some student studies": ∃x (Student(x)∧Studies(x))\exists x\, (\text{Student}(x) \wedge \text{Studies}(x)). Use ∧\wedge with ∃\exists.
  • "No student studies": ∀x (Student(x)→¬Studies(x))\forall x\, (\text{Student}(x) \rightarrow \neg\text{Studies}(x)), equivalently ¬∃x (Student(x)∧Studies(x))\neg\exists x\, (\text{Student}(x) \wedge \text{Studies}(x)).

Exam point. ∃x (Student(x)→Studies(x))\exists x\,(\text{Student}(x) \rightarrow \text{Studies}(x)) is a classic mistake: it is true as soon as anything is not a student.

Negating quantifiers. ¬∀x P(x)≡∃x ¬P(x)\neg \forall x\, P(x) \equiv \exists x\, \neg P(x) and ¬∃x P(x)≡∀x ¬P(x)\neg \exists x\, P(x) \equiv \forall x\, \neg P(x).

Order matters. ∀x ∃y Loves(x,y)\forall x\, \exists y\, \text{Loves}(x, y) (everyone loves someone) differs from ∃y ∀x Loves(x,y)\exists y\, \forall x\, \text{Loves}(x, y) (someone is loved by everyone). The second implies the first, not the other way round. Quantifiers of the same kind commute: ∀x∀y≡∀y∀x\forall x \forall y \equiv \forall y \forall x.

Distribution. ∀x (P∧Q)≡∀xP∧∀xQ\forall x\,(P \wedge Q) \equiv \forall x P \wedge \forall x Q and ∃x (P∨Q)≡∃xP∨∃xQ\exists x\,(P \vee Q) \equiv \exists x P \vee \exists x Q. But ∀\forall does not distribute over ∨\vee, and ∃\exists does not distribute over ∧\wedge.

Inference in first-order logic. Universal instantiation replaces a ∀\forall variable with any ground term; existential instantiation replaces an ∃\exists variable with a new constant (a Skolem constant). Unification finds a substitution that makes two expressions identical, e.g. Knows(John,x)\text{Knows}(John, x) and Knows(y,Mary)\text{Knows}(y, Mary) unify with {y/John,x/Mary}\{y/John, x/Mary\}. Generalised modus ponens combines unification with modus ponens.

Solved example

Example 4. From ∀x (Man(x)→Mortal(x))\forall x\,(\text{Man}(x) \rightarrow \text{Mortal}(x)) and Man(Socrates)\text{Man}(Socrates): instantiate x=Socratesx = Socrates, then modus ponens gives Mortal(Socrates)\text{Mortal}(Socrates).

आपने इस नोट का मुफ़्त 26% हिस्सा पढ़ लिया

आगे पढ़ने के लिए Google से साइन इन करें। यह मुफ़्त है, एक टैप में होता है, और साथ में मिलता है:

  • इस नोट से 10 अभ्यास सवाल
  • हर नोट पूरा, साथ में PDF लाइब्रेरी
  • आधिकारिक पिछले पेपर समय-सीमा वाले टेस्ट की तरह, व्याख्या के साथ
  • डाउट के लिए AI ट्यूटर, हिंदी या अंग्रेज़ी में
  • आपकी प्रगति, गलतियाँ और स्टडी प्लान हर डिवाइस पर सेव
आगे पढ़ें, मुफ़्त