COL703 – Logic for Computer Science

July 2024 – November 2024

Course timings & Venue:

B slot: Mondays & Thursdays 0930 – 1100, in Block VI, LT II.



What is this course about, and why should I take it?

Logicians will often tell you that the primary raison d'être of logic is to systematically evaluate arguments for deductive validity, or something equally abstruse along those lines. So why should you, a computer scientist, bother with logic at all? Because, as anyone who has ever written a program beyond "Hello, world!" knows, writing code is hard. Writing good code is even harder, and this starts even before we have written any code at all! Are you sure that what you think you want is really what you want? Will your code actually work? How reasonable are the assumptions you have made along the way? These are questions that logic can help you think about in a systematic way.

The objective of this course is to learn fundamental ideas that help us create abstract models of systems in the real world, so we can then ensure that they behave as they should. This course will essentially cover concepts related to how to model complex systems abstractly while making good choices, as well as how to reason about these systems automatically, with a view to formal verification.


Prerequisites

This fundamental material covered in this course is fairly abstract and theoretical, and will therefore require some mathematical acumen -- students should, at the very least, be able to write and understand rigorous formal proofs, especially those involving various kinds of induction. There will also be some programming involved to implement various concepts. You should have taken at least one of the following courses (or equivalents thereof):


Evaluation policy

  • Assignments: 20%. We will follow a graceful degradation policy: For every day that you use beyond the indicated deadline, you lose 20% of marks for that assignment -- if you submit anything later than 5 days past the deadline, it will not be evaluated.

  • Minor: 20%. No re-minor will be conducted. If you miss the minor for a medical reason (with appropriate documentation produced within one week of the minor), the major marks will be scaled up accordingly.

  • Major: 40%. The syllabus for the major exam will include everything covered in the course.

  • Quizzes: 15–20%. There will be some surprise quizzes conducted in class at various points during the semester. Absence in a quiz is directly marked 0. No make-up quizzes will be conducted.

  • In-class participation, attendance etc: 0–5%.

  • Pedagogical experiment surveys: 0–5% Bonus.

  • "A few of my favourite things": 0–5% Bonus.

Audit pass needs at least a B- overall, including at least 10% out of the 15–20% earmarked for quizzes.

Deviation of any sort from the IIT Delhi honour code (copying, plagiarism, collaborating on gradable items where explicitly disallowed etc. – see here for more examples) will summarily result in an F grade, or in case of audit, an NF, and potentially further disciplinary action.

Reference material

We will follow notes presented in class, for the most part, which will be uploaded here. Some external references for much of the course are listed below (caveat emptor: notation used in these notes/books might significantly differ from the ones used in class).

Lecture Notes & Reference Material

Date Slides References and suggested follow-up reading (if any)
22 July, 2024

Course policy and introduction

25 July, 2024

Sets, functions, and relations

29 July, 2024

Orderings and induction

  • Section 14 in Naive Set theory by Paul Halmos, PDF found here

1 August, 2024

Propositional logic

5 August, 2024

Propositional logic (contd.)

8 August, 2024

More propositional logic

Here is a link where you can play around with equivalences and normal forms for various expressions. Make sure that you use the English language toggle on the top right if it loads in Dutch. Most of the conversion rules should be easy enough to figure out (they are identities we have covered in class). The only exception is the rule for Equivalence, which is: p ⇔ q iff (p ∧ q) ∨ (¬p ∧ ¬q).

12 August, 2024

Resolution

13 August, 2024

The Hilbert system

22 August, 2024

Completeness for the Hilbert system

Here is a list of proofs you should try to do using the Deduction Theorem. These are fairly fundamental statements and are often useful. Try to do the proofs in order, since some later ones might need you to invoke the ones that came prior.

Here is a link where you can play around with proofs in the Hilbert system. Make sure that you use the English language toggle on the top right if it loads in Dutch. The three axioms are called A, B, and C. A and B are the same as our H1 and H2, but axiom C is taken to be (NOT p IMPLIES not q) IMPLIES (q IMPLIES p).

29 August, 2024

Propositional logic: Wrap up

This link has an excellent write-up about the Compactness Theorem and the Graph Colouring application.

Murdle is an excellent, fun way to sharpen your logical inference skills. Try to code up today's Murdle in propositional logic! (You need to come up with the right propositions and the right connectives. This will often require some human meta-reasoning using the given clues.)

31 August, 2024

Z3 Walkthrough

You can play around with other Z3 exercises here. Z3 is a solver that primarily tries to solve the Satisfiability problem, which is known to be hard. However, the problem is so common across subfields that enterprising computer scientists have come up with inventive ways to solve this problem anyway. Recommended reading related to SAT solving includes the DPLL algorithm (which is related to Resolution) and Conflict-Driven Clause Learning (which tries to "learn" a satisfying valuation for the given expression). Come talk to me if you're interested in learning more or working on extensions of any of these!

2 September, 2024

First-order logic

5 September, 2024

More first-order logic

9 September, 2024

Review lecture

19 September, 2024

FO: Truth and models

Chapters 21 through 24 of Introduction to Formal Logic by Peter Smith contain many examples.
23 September, 2024

FO: Normal forms

26 September, 2024

Unification

30 September, 2024

Unification and resolution

3 October, 2024

FO resolution

This link is an excellent repository of exercises that you can try out to get better both at modelling "real life" statements in FOL, and at performing resolution (to prove the conclusion from the axioms).

FO Resolution is often used in automated theorem proving. Here is a nice little implementation in Python. Caveat: Theorem proving using resolution is not complete (why not?), since the rule does not yield a complete proof system for FOL (unlike the PL resolution rule), so you might not be able to prove everything you might want to.

14 October, 2024

FO completeness