CS313K Logic, Sets, and Functions
Spring, 2010

Basics

Objectives

This course is designed to teach you to use the predominant mathematical notations and systems in computer science, how to formalize ideas mathematically, and how to prove that those formal concepts have certain properties. This is a required course for CS majors. To find out why, click here. For some advice on how to succeed in this course, click here.

Textbook

The second lecture will start with a quiz, so you must accomplish all three of the following tasks before class on Thursday, Jan 21! Do not procrastinate.

Bring your notes, iClicker, some scratch paper, and a pen or pencil to every lecture.

Errata for the Notes

On page 5, the claim that (f (g x y)) is ill-formed because it contains an ``ill-formed interior term'' is wrong! It's not ill-formed at all. (f (g x)) would be an example of the kind of ill-formed term meant.

On page 22, Question 34 should ask ``what is the value of (fn-q34 x) when x is a natural number?'' As phrased, the question is ill-formed because fn-q34 has arity 1 but the question talks about (fn-q34 x y).

The notes list a number of homework problems due on Mar 16. That's during Spring Break. Those homework problems are due Mar 23 instead. See the (corrected) due dates in the Homework section below.

Reading Assignments

This is college. You must read ahead to know what is going on in the lectures. The reading schedule is implicit in the notes. Each section is marked with the date of the lecture at which that section will be discussed.

Every lecture — including the second — will start with an iClicker quiz over the assigned reading and you will be graded on the quizzes. I cannot stress enough the importance of your taking responsibility for the reading.

We're going to cover roughly 240 pages of the notes. The course marches on relentlessly, every lecture covering new material. Keep up!

I will not remind you of the reading from week to week. That is your responsibility! It will sometimes take a day or two or read the material, so I recommend that after every class you look ahead to see what the next reading assignment is and plan your time accordingly before the next class. Do not wait until an hour before class! That won't be enough time.

I may have to change pace of the reading assignments. Changes will be announced in class. Pay attention.

When you read the material, work some of the problems. Program up small examples to test your understanding. Do not study passively! Just reading — without thinking through the consequences of what you're reading — is usually a waste of time.

The quizzes will often refer to the notes and I'll expect you to answer my questions with your clickers. You will be graded on the answers. So be sure you

Last year (Spring, 2009) I had a rule that if more than half the students answered a quiz question incorrectly, I did not count the question. I've decided that is a bad rule that punishes the best students. This year (Spring, 2010), every question I ask will count.

Attendance

Attendance is taken in every lecture via the iClicker quiz. It will be necessary to attend class and take the quizzes to make a good grade.

Show up! And bring your clicker! Please sit in the front.

Homework

There will be weekly homeworks.

Homework is always due on the Tuesday before class. All homework solutions must be typed in plain ASCII and submitted via the turnin facility. (Be sure to turn your homework into your CS313K folder and not some other class! No credit will be given for homework turned in to another class!)

Your solution to the first homework should be named hw1.txt, the second hw2.txt, etc. The text file should start with your name, EID, and a title (e.g. “CS313K Spring 10 Homework i”).

The official list of homework problems and due dates is given below. Remember: well formatted plain ASCII, via turnin, before 3:30 pm, on the Tuesdays listed below.

hwidue dateProblems
1Jan 2614, 23, 24, 25, 29, 33
2Feb 249, 50, 55, 57, 60, 65
3Feb 989, 92, 93, 109, 112, 114, 115
4Feb 23125, 130, 131, 132, 133
5Mar 2135, 137, 146, 148, 151, 160, 164
6Mar 9167, 168, 169, 170, 174, 181
7Mar 23194, 199, 215, 216, 219
8Mar 30225, 226, 230, 235, 237
9Apr 13266, 268, 269, 270, 274, 281, 282, 283
10Apr 20289, 292, 293, 296, 314, 316
11Apr 27318, 320, 321, 322, 323, 324, 331, 337, 338, 355, 366, 372
12May 4379, 388, 393, 395, 403

I reserve the right to change the homework assignments in response to the pace of the lectures. Changes will be announced in class and the list above will be modified. Check this list weekly if you want to be sure you're doing the right problems!

For your convenience, the printed copy of the textbook has the assigned homework problems marked with stars (★★★) along with the due date. Of course, if I change the assignments, the starred problems in the book will no longer be current. I recommend that you mark your books when I make announcements in class -- and check the list above weekly.

Some symbols we use in class and in the notes are not ASCII, e.g., ∧, ∨, ¬, →, ↔, ∀, ∃, ∈, ⊆, ∩, ∪. There is a table of ASCII substitutes in Appendix D of the notes. For example, you're told there to type “p --> q” for “pq”, and “(all v p)” for “(∀ v : p)”.

Warning: You will get a 0 for any answer that violates the following rules. Every “formula” must be syntactically well-formed. Nothing should extend beyond the 80th column -- lines should not be truncated or wrap around when viewed in a window 80 characters wide. Finally, if the grader feels that insufficient effort has been made to display a formula sensibly, he or she is free to assign a 0 for that answer even if it is correct! The book discusses this at length in “Syntax” section of Chapter 4.

You may work on your homework in groups, but each person must prepare and turn in his or her own write-up. Working in groups is an excellent way to learn new material, but writing it down yourself is an great way to make sure you understand it. Don't think that you understand because someone in your group understands! And remember, you will work alone during the exams and the only way to do well in the class is to master the material.

It is considered cheating to turn in somebody else's homework as your own. In the CS department, cheating and facilitating cheating by others results in a course grade of F.

Just to be clear:

Tools

You will be expected to define and run programs in the ACL2 programming language. ACL2 is probably unfamiliar to you, but it is simple to learn.

The first homework assignment contains explicit instructions to get you started with the ACL2 system. It introduces an Eclipse interface to ACL2, called ACL2s, written and maintained by Peter Dillinger, Pete Manolios and Harsh Chamarthi, of Northeastern University, Boston. ACL2s is available on all the CS department's public machines. You may wish to install it on your own laptop but that is not necessary.

If you do install ACL2s on your laptop, you might want to look at this Installation FAQ.

Do not be nervous about learning a new programming language. In your careers as CS students and then as computer scientists you will learn new languages regularly! Get used to it!

Note: ACL2 can be run under Emacs and directly from Windows or Unix. You may see me using it that way in class from time to time. But the preferred interface for novices is ACL2s, The ACL2 Sedan for Eclipse. It's called the “sedan” for good reason. Driving full ACL2 is like driving a race car: one mistake and you're in the ditch.

Exams and Scheduled Quizzes

There will be two midterms and a final. See above for the dates.

There will be a scheduled quiz in every lecture except the first one and the two lecture periods devoted to the midterms.

Email and Discussion Forum

All students should become familiar with the University's official e-mail student notification policy. I may occasionally use email to communicate with the students in the class and it is your responsibility to keep your UT Direct email address current and to check it frequently and regularly.

Discussion Forum To Be Determined (In Spring, 2009, online discussion forums were organized. If that happens this time, I'll announce it here and in class.)

Grading

Grades are determined by the total number of points earned in each of several activities: attendance at TA sessions, scheduled quizzes, homeworks, the two midterm exams, and the final exam. The total available points is 1240, distributed as follows:
activityopportunitiespoints/opportunitytotal
TA sessions1510150
Quizzes2710270
Homeworks1210120
MidTerm 11200200
MidTerm 21200200
Final Exam1300300
total for course1240

Your final score will be the total number of points earned divided by 12.40 and rounded up to an integer. This gives an integer between 0 and 100.

Letter grades will be assigned in the conventional way:

93 ≤ score ≤ 100A
90 ≤ score < 93A-
87 ≤ score <   90B+
83 ≤ score <   87B
80 ≤ score <   83B-
77 ≤ score <   80C+
73 ≤ score <   77C
70 ≤ score <   73C-
67 ≤ score <   70D+
63 ≤ score <   67D
60 ≤ score <   63D-
  0 ≤ score <   60F

Important Notes

Each quiz is worth 10 points. But some quizzes may have as few as 2 questions and others as many as 15 or so. The average number of questions per quiz will be about 6.

Quiz, homework, and test scores are kept as integers between 0 and 10. When computed from fractions, they are rounded up. For example if you answer 5 questions correctly on a quiz with 6 questions, you will receive ceiling(10 × 5/6) = 9 points, not 8.3 points. Midterm and final exam scores are kept as integers in the range 0 to 100.

Partial credit is not given on quiz answers.

Quiz scores are not curved.

If any student in a lecture is discovered with more than one clicker, the clickers will be confiscated until the situation is sorted out by the instructor. If it is determined that one student was taking quizzes for another it will be considered cheating. The CS department penalty for cheating is a course grade of F and referral to the Dean of Students.

While discussion of the homework problems among students is encouraged, each student must prepare his or her own homework submissions. Turning in somebody else's work as your own is an example of cheating. The CS department penalty for cheating is a course grade of F and referral to the Dean of Students.

If you ever wonder whether some behavior you're contemplating would be considered cheating, don't do it! If it's in this course, ask me. If it's in another course, ask the professor in charge.

Partial credit is not given on homework.

Failure to be in your TA session when attendance is taken, for any reason other than an excused absence, results in a 0 that day. No partial credit is given for late arrivals.

Failure to turn in a homework on time, for any reason other than an excused absence, results in a 0 on that homework. No partial credit is given for late homeworks.

Failure to take a midterm or the final exam will result in a score of 0. Except for excused absences, make up exams will not be scheduled.

No “slip points” are provided. However, it is possible to make an A without perfect performance. See Effects of Various Coping Strategies.

If you are dissatisfied with a grade you receive on an assignment or test, you must submit your complaint via email, along with supporting evidence or arguments, to your TA within one week of the date the teaching staff first attempted to return the assignment or test to you.

Questions about your homework grades are to be sent to your TA.

There are no opportunities for extra credit in this course.

Course grades may be adjusted with pluses and minuses at the instructor's discretion.

Effects of Various Coping Strategies

In this section I illustrate the implications of this grading scheme by describing several hypothetical performance records and giving the resulting score.

First, note how expensive cheating is. A single quiz or homework assignment is worth just 10 points out of 1240, less than 1% of your grade. But giving your clicker to somebody to operate on your behalf, turning in somebody else's work, or facilitating such behavior by another student results in a course grade of F. That is, you're risking failing the entire course to make less than 1% of the total available points.

If you miss one TA session and one Quiz (lecture) and fail to turn in one homework, but you score 80% on the remaining quizzes, homeworks, midterms, and the final exam, you'll make a B-.

But if you miss two TA sessions and two Quizes and otherwise perform as above, you'll make a C+.

If you miss one TA session and one Quiz (lecture) and fail to turn in one homework, but you score at least 90% on the remaining quizzes and homeworks and you score 90 on two of the exams and 91 on the other, you'll make an A-.

Thus, it is possible to make an A- without perfect attendance or perfect homework performance. Because of this, there are no “slip points.”

It is less risky to attend all the TA sessions and lectures.

If you have perfect attendance at the TA sessions and lectures and score 90 on every quiz, exam, and homework you turn in, you can afford to miss no more than 3 homeworks and still make an A-.

You could also make an A- by attending all the TA sessions and lectures, make a 85% on the quizzes, average 95% on the homeworks and turn in all of them, and make an 88 and 92 on the midterms and then a 90 on the final.

Finally, if you ace the exams, with three perfect 100s, and get perfect scores on all the homeworks, but don't come to lectures or the TA sessions, you'll make a D+! So you can't do well in this class without attending the lectures and your TA sessions.

You can experiment with your own strategies using the following ACL2 function. If you can't figure out how to use it after a couple of weeks, you won't pass. To have ACL2 check that you're calling it with the right type of arguments, do :set-guard-checking t before you evaluate sample scenarios.

(defun score (tax qzx qzv hwx hwv mt1 mt2 fin)

 (declare 
   (xargs
    :guard (and (and (natp tax) (<= tax 15))
                (and (natp qzx) (<= qzx 27))
                (and (rationalp qzv) (<= 0 qzv) (<= qzv 1))
                (and (natp hwx) (<= hwx 12))
                (and (rationalp hwv) (<= 0 hwv) (<= hwv 1))
                (and (rationalp mt1) (<= 0 mt1) (<= mt1 1))
                (and (rationalp mt2) (<= 0 mt2) (<= mt2 1))
                (and (rationalp fin) (<= 0 fin) (<= fin 1)))))

; Returns the final score, between 0 and 100, of a student with
; the indicated performance, where the types of the arguments
; are as given above.  Their meanings are:

; tax = number of TA sessions missed
; qzx = number of Quizzes missed
; qzv = average grade on quizzes taken
; hwx = number of Homeworks missed
; hwv = average grade on homeworks turned in
; mt1 = grade on midterm 1
; mt2 = grade on midterm 2
; fin = grade on final exam

; Note that the function requires fractional inputs between 0 and 1
; to represent the average scores on the quizzes, homeworks, and
; tests. I multiply those by the total number of points available 
; for each category.  In actual grading, we will just sum the number
; of points earned on the quizzes, the homeworks, and the tests.

  (let ((TA 10)
        (QZ 10)
        (HW 10)
        (M1 200)
        (M2 200)
        (FN 300))
  (ceiling
   (* 100
      (/ (+ (* (- 15 tax) TA)
            (* (- 27 qzx) (* qzv QZ))
            (* (- 12 hwx) (* hwv HW))
            (ceiling (* mt1 M1) 1)
            (ceiling (* mt2 M2) 1)
            (ceiling (* fin FN) 1))
         (+ (* 15 TA) (* 27 QZ) (* 12 HW) M1 M2 FN)))
   1)))

For example, the outcome of the scenario

Suppose I miss 2 TA sessions and 1 lecture. I think I can score an average of 73% on all the other quizzes. I haven't missed turning in any homework yet. I can keep that up — it's easy since all the homeworks are marked in the book So my missed homeworks will be 0. I'm sure I can maintain an average of 95% on the homeworks — I have a couple of friends in the course who explain things to me. I got a 78% on the first midterm. I think I can get an 85% on the next one and I'll assume I get just 80% on the final exam. What will my final grade be?
is determined by
(score 2 1 73/100 0 95/100 78/100 85/100 80/100)
which computes to 81. The student will make a B-.

Excused Absence

Religious Holy Days: A student who is absent from an examination or cannot meet an assignment deadline due to the observance of a religious holy day may take the examination on an alternate day, submit the assignment up to 24 hours late without penalty, or be excused from the examination or assignment, if proper notice of the planned absence has been given. Notice must be given at least fourteen days prior to the classes scheduled on dates the student will be absent. For religious holy days that fall within the first two weeks of the semester, notice should be given on the first day of the semester. It must be personally delivered to the instructor and signed and dated by the instructor, or sent via certified mail, return receipt requested. Email notification will be accepted if received, but a student submitting such notification must receive email confirmation from the instructor. A student who fails to complete missed work within the time allowed will be subject to the normal academic penalties.

Disability Related Needs: Please notify me of any modification/adaptation you may require to accommodate a disability-related need. You will be requested to provide documentation to the Office of the Dean of Students in order that the most appropriate accommodations can be determined. Specialized services are available on campus through Services for Students with Disabilities, SSB 4th floor, A5800, 471-6259, TTY 471-4641

Emergencies and Illness: Documented emergencies and illnesses will be dealt with by the instructor. For best results, communicate with me before you miss a midterm or the final and be prepared to supply written, verifiable evidence of the condition.

Code of Conduct: For important other advice about expectations and conduct, see
The Computer Sciences Department Rules to Live By.























Acknowledgements

I thank the following people for their help in preparing for this course: Bob Boyer, Matt Kaufmann, Warren Hunt, Peter Dillinger, Pete Manolios, Harsh Chamarthi, Sandip Ray, Morrie Schluman, Mike Scott, Bruce Porter, David Rager, Behnam Robatmili, Ian Wehrman, Nathan Wetzler, Mark Reitblatt, and all the TAs, tutors, departmental academic staff, and the ACL2 research community.

Why We Make CS Majors Take This Course

In science, mathematics is used to describe the world and to analyze the behavior and interactions of objects in the world. Mathematics is necessary because the objects we describe and analyze — planets, reactions, supernovas, molecular docking, microprocessors, algorithms, networks — are so complicated that we cannot keep all the interactions in mind at once. We need the precision and power of mathematics to help us keep things straight in our heads.

In physics, for example, the dominant mathematical systems are calculus and differential equations. But in computer science, the dominant mathematical systems are mathematical logic, set theory, and the theory of functions and relations. The difference is that physics deals mainly with continuous, smoothly varying systems, while computer science deals with discrete, digital systems. Continuous mathematics, like the Real Analysis and Calculus, is of little use in analyzing a system that goes from one state to another without any intermediate state.

Thus, the mathematical language of CS is often very different from that of physics. In physics, your professors will use ∂ x/∂ y, ∫, and lots of algebraic notation. In CS, your professors will use symbols you've never seen before: ∧, ∨, ¬, →, ↔, ∀, ∃, ∈, ⊆, ∩, ∪, etc. To understand your future CS courses and to speak clearly and precisely to your computing colleagues, you need to learn the rudiments of these mathematical systems. That's what this course is about.

Mathematical logic, set theory, and function theory are deep intellectual subjects. Some of the greatest minds in computing — Godel, Turing, von Neumann, Minsky, McCarthy, Dijkstra, Knuth, Newell, Rabin, Hoare, Cook, Karp, Emerson, etc., — have made fundamental contributions that can only be expressed in these terms. Some of the deepest insights mankind has had about the nature of truth and the power of computation stem from these subjects. Many of the basic ideas of programming languages and of system design — variables, objects, methods, macros, modularity, recursion, types, interpreters, representation, abstraction — were first explored in the context of mathematical logic.

How to Succeed in CS313K

You've probably never come across any form of mathematics quite like what you'll see here. So it is going to seem really strange and hard to grasp.

But what are the skills you have as computer scientists? You can

These are the same skills it takes to master logic, sets, and functions.

The secret to success is practice, practice, practice. You were not born with the ability to ride a bike, hit a ball, dance, or play a musical instrument. You picked up these and almost all your other skills by hard work and practice. So too with proving theorems and reading set notation!

Nobody is born with an innate comprehension of mathematical logic, set theory, or the theory of functions! Everyone who knows how to do this stuff learned it! We learned it by hard work and practice. You can too! But you have to stay with it.

Here are the ten most important things to do to succeed in CS313K:

  1. never fall behind
  2. schedule time to do your reading in advance of every class
  3. think about the questions in the text
  4. spend way more time on this course than I do — I already know this stuff
  5. don't memorize; understand the new language you're learning
  6. come to every lecture and TA section
  7. answer every clicker question and compare your answers to the right ones
  8. ask questions when you don't understand
  9. visit me or the TAs or the tutors whenever you feel confused
  10. never fall behind