Introduction to Logic
CS157 Autumn 2025
Lectures TTh 13:30 - 14:50 Gates B1
Lessons Lecture Slides Lecture Recordings Ed Discussion Tests

Welcome

Niels Bohr to Albert Einstein: "You are not thinking; you are just being logical."

CS 157 is a rigorous introduction to Symbolic Logic from a computational perspective. It focusses on the encoding of information in the form of logical sentences; it covers various methods for reasoning with information represented in this form; and it provides an overview of logic technology and its applications (in mathematics, science, engineering, business, law, and so forth). Topics include the syntax and semantics of Propositional Logic, Relational Logic, and Term Logic, validity, contingency, unsatisfiability, logical equivalence, entailment, consistency, direct deduction (Hilbert), natural deduction (Fitch), refutation reasoning (Resolution), mathematical induction, reasoning with equality, compactness, soundness, completeness.

The course is divided into three main sections - Propositional Logic, Relational Logic, Term Logic (Logic with function symbols). See the table below for a tentative schedule of lessons, quizzes, and reviews.

WeekTuesdayThursday
1 September 22
Introduction
September 24
Propositional Logic
2 September 29
Propositional Analysis
October 1
Direct Proofs
3 October 6
Natural Deduction
October 8
Refutation Proofs
4 October 13
Review
October 15
Quiz 1

5 October 20
Relational Logic
October 22
Relational Analysis
6 October 27
Fitch Proofs
October 29
Review
7 November 3
No Class
November 5
Quiz 2

8 November 10
Term Logic
November 12
Induction
9 November 17
Equality
November 19
Logic in Logic
Thanksgiving Week
10 December 1
Review
December 3
Quiz 3

December 8
Optional Final
 

This year, the lectures will take place in Gates B1 on Tuesdays and Thursdays from 1:30 to 2:50. There will be in-person office hours with the teaching staff. Times and locations will be posted on this page when they are finalized.

All of the materials for the course are online. Click on the "Lessons" tab at the top of this page to access these materials. There are links to textbook chapters, lecture slides, interactive exercises, puzzles, and sundry other items. Note that, as you proceed through the online materials, you may occasionally encounter technical problems. Apologies in advance if this happens to you. We are constantly working on the course. You may get extra credit for reporting such problems (especially if your reports are more constructive than irate).

Collaboration with your fellow students is acceptable and strongly encouraged. Feel free to discuss the subject matter and the problems either directly or using Ed Discussion. Our experience has shown that it is useful for students to work together to understand the material of the course and to solve problems. That said, you are expected to do quizzes in this course on your own; and you are responsible for understanding and being able to explain your answers.

Your grade for the course will be based on your scores on three online quizzes - one on Propositional Logic, one on Relational Logic, and one on Term Logic. The first quiz will count for 40% of your grade; the second will count for 30%; and the third quiz will count for 30%. We will also award a few points of extra credit based on discretionary factors, such as class attendance, participation in the Forum, and work on the puzzles. As preparation for the quizzes, we highly recommend that you review the online exercises, as the problems on the quizzes will closely resemble these exercises. In the past, we have offered an optional final for those who wish to make up for weak performance on the quizzes. We will almost certainly do the same this year.

Logical Properties: Consider the sentence x.∀y.((p(x,y) ⇒ q(x,y)) ∨ (q(x,y) ⇒ p(x,y))). Is this sentence valid (always true), contingent (sometimes true and sometimes false), or unsatisfiable (always false). Answer: It is always true, i.e. valid. Why?

Relational Proof: A binary relation p is symmetric if and only if ∀x.∀y.(p(x,y) ⇒ p(y,x)). It is transitive if and only if ∀x.∀y.∀z.(p(x,y) ∧ p(y,z) ⇒ p(x,z)). It is irreflexive if and only if ∀xp(x,x). Show that if p is symmetric and transitive and irreflexive, then it is empty.

Suarez Puzzle: Suarez is a (slowly) recovering liar. He lies on six days of the week, but on the seventh day he always tells the truth. One week, he made the following statements on three successive days. Day 1: "I lie on Mondays and Tuesdays. Day 2: "Today, it's Thursday, Saturday, or Sunday. Day 3: "I lie on Wednesdays and Fridays." On which day does Suarez tell the truth?

Safecracking Puzzle: There is a combination safe with four switches on the front, each with three positions (low, medium, and high). If the switches are set into an opening combination, then when you try to open the safe, it will open; otherwise, no dice. In general, there are 3^4 (i.e. 81) possible combinations. However, this is a cheap safe; and only two of the switches actually matter; if you set those two switches right, the safe will open. Unfortunately, you do not know which are the important switches or which positions work. What is the minimum number of combinations you must try that will *guarantee* to open the safe?

Michael Genesereth
genesereth@stanford.edu
Office Hours: Tue 3:00 pm - 4:00 pm
Location: Gates 308
Vaishnav Garodia
vgarodia@stanford.edu
Office Hours: Sat Sun 12:00 pm - 2:00pm
Location: Zoom
 
Kelvin Waititu
kwaititu@stanford.edu
Office Hours: Fri 9:00 am - 11:00 am
Location: Huang Basement
Office Hours: Mon 6:00 pm - 8:00 pm
Zoom: Zoom

Feedback