Logic and Computation
CS 2800 Fall 2023

Khoury College of Computer Sciences
Northeastern University

Goals

By the end of this course, you will:
  1. Understand how logic is used to specify the semantics of a simple functional programming language.
  2. Learn how to formally specify contracts, invariants and properties of programs.
  3. Know how to use property-based testing to gain confidence in the correctness of programs.
  4. Explore Boolean logic and its applications, including to security.
  5. Understand and effectively use various proof techniques to reason about programs, including propositional reasoning, case analysis, proof by contradiction, instantiation, equational reasoning and induction.
  6. Learn how to write rigorous paper and pencil proofs, as well as mechanized proofs that require lemmas and generalization.
  7. Understand the distinctions between P/NP and decidability/undecidability.
  8. Understand basic undecidability proofs based on Cantor diagonalization.
  9. Learn how to prove termination of code using measure functions and generalizations based on infinite numbers.
  10. Explore some of the considerations involved in formally reasoning about imperative programming languages such as C and Java.
  11. Learn how to reason about simple imperative programs using loop invariants.
  12. Explore the connections between termination and induction.
  13. Learn how to formally reason about algorithms and how to prove functional equivalence of programs.
  14. Explore refinement and observational equivalence.
  15. Learn how to use logic to evaluate informal arguments by identifying hidden assumptions, inconsistencies, fallacies and the logical structure of such arguments.

Books and Supplies

The course book will be freely distributed to you during the semester. Click on Lecture Notes on your left.

An optional book that includes a lot of exercises is: Computer Aided Reasoning. Kaufmann, Manolios, Moore. You can order it from here. Please note that the book was written for at least upper level undergraduate students, so expect parts of the book to be hard. Also, in class we use ACL2s, a version of ACL2 that includes contracts and lots of other things that are not mentioned in the book. Nevertheless, this is the standard reference for ACL2 and contains many exercises whose solutions are available online.

Software

We will be using the ACL2s system. Please download it and install it on your machines, using the instructions here. It is also available on the Khoury Virtual Desktops, which allow you to run ACL2s with only a browser.

Forum

I will provide a Piazza-Based Web forum that can be used by students to ask questions and exchange wisdom while completing the homeworks in this course. You are expected to check it every day (you can configure it to send you daily updates), participate actively, and use it as a first place to post questions related to homeworks in this course. Please use the forum to post questions and answers that may be useful to others. Specifically, clarification questions about the homework, such as "What is the precise interpretation of homework question 2b" should be posted on the forum. Also, any questions at all about the material covered in class should be posted on the forum, e.g., "What do I wind up with when I apply the induction scheme for foo on this conjecture?"

Exams

There will be two exams. They will take place at the following times:

There is no final.

Grading

Grades will be determined as follows.

Quizzes will occur regularly. Be prepared for a short quiz every day. Quizzes will probably happen using Canvas. Only a subset of the quizzes might be graded. If you are not present for a quiz or if you do cannot log in to Canvas, you will get 0 points. We will drop the lowest 3 quizzes.

Homeworks will be given about once a week. We will drop your lowest homework grade. You will mostly work in groups. We will give you instructions on group sizes and composition. We recommend that you to first try to solve the problems on your own. Then meet with your partners to go over your solutions and solve any unresolved problems. We may only grade a subset of the problems assigned. Homeworks will be due on Tuesday at 11:00PM, unless otherwise noted.

Grading Notes

Prerequisites

CS 1800 and CS 2500.
If you do not have this background you should get the permission of the instructor. Our policy is that we do not grant exemptions if you did not getting passing grades in both the prerequisites: experience has shown that this is the best policy for students.

Academic Integrity

Read and intimately familiarize yourselves with the Northeastern Academic Integrity policy.

Warning: We do not tolerate any violations. If we believe that you violated the policy, we will report you to the university and to the college. On top of that, your grade for the course will be reduced to an F. Note that the university and the college can impose further penalties, including not allowing you to go on co-op, not allowing you to work at the university; even expulsion from the university is possible in severe cases.

For example, here is something you cannot do, but again, read the full policy, the course contract and see Mitch Wand's Web page on the topic.

Unauthorized Collaboration: The University defines unauthorized collaboration as instances when students submit individual academic works that are substantially similar to one another. While several students may have the same source material, the analysis, interpretation, and reporting of the data must be each individual's independent work.

You can only collaborate with your partners on homework problems. Besides staff, the use of any other sources for homework solutions is a violation of the academic integrity policy. For example, you cannot ask students for hints or to look at their homework solutions. For exams you have to work alone and cannot use any resources beyond those explicitly allowed.

If you have any doubts at all whether something is allowed or not, please ask! For example, you can (and are encouraged to) discuss the material we cover in class with anyone. Collaboration, interaction, debate and discussion is encouraged, except for graded work as outlined above.

Class Guidelines, Policies and Notices

Tentative Schedule

Lectures
  1. Introductions & motivation
  2. Course overview, Programming review
  3. Designing data-driven programs, the ACL2s development environment
  4. Basic data types, expressions, syntax & semantics of atomic data and associated primitive functions
  5. Syntax & semantics of lists, design considerations of the ACL2s core language, contracts, termination, quote, let
  6. Datatypes: enumerated, range, product, record, union, list, (mutually) recursive; pattern matching
  7. Contract-based testing, expression coverage and designing programs
  8. Property-based testing
  9. Property-based testing in industry, Fuzzing, security applications
  10. Boolean logic, truth tables, characterization of formulas, Security: one-time pads
  11. Introduction to P=NP, Properties of Boolean operators, Proof methods: instantiation, case analysis, equational proofs, decision procedures
  12. Boolean logic in ACL2s, Normal forms
  13. Set Theory Connections, Boolean Algebra based on sets, resolution-based SAT solving
  14. Limitations of Boolean logic, intro to equational reasoning for programs, Axioms for equality, cons-first-rest axioms, definitional axioms, instantiation, contract checking and completion
  15. Equational reasoning with nested Boolean operators, derived context
  16. Context vs. theorems, numeric reasoning in C & other languages
  17. How to prove theorems using equational reasoning, formalization examples, proof examples
  18. Definitions: soundness, termination, contracts, the ACL2s Definitional Principle
  19. Termination, measure functions
  20. Using termination to show soundness of common recursions schemes, big-Oh analysis as a refinement of termination
  21. Undecidability of halting problem
  22. Proof by contradiction, mathematical induction, well-foundnesses, a proof that mathematical induction works, how to extract induction schemes from admissible recursive functions
  23. Using induction to prove program correctness
  24. Data-function-induction trinity, Importance of termination
  25. Induction like a professional
  26. Generalization, lemma generation, dealing with induction failure
  27. Intro to reasoning about accumulators
  28. Tail recursion: efficiency considerations, how to prove correctness
  29. Reasoning about algorithms: sorting, correctness
  30. Reasoning about imperative programs: defining the semantics of a simple while language in ACL2s
  31. Reasoning about imperative programs using loop invariants; checking such proofs in ACL2s
  32. Reasoning about imperative programs and security
  33. Compiler correctness
  34. Using logic to reason about societally relevant topics
  35. A look back: Logic and the birth of computer science; A look forward: what's next