CSCI 301 - Formal Languages and Functional Programming

Scott Wehrwein

Fall 2024

Course Overview

Syllabus and Course Website (you are here): https://facultyweb.cs.wwu.edu/~wehrwes/courses/csci301_24f

Credits: 5

Course Staff:

Lecture (CF 226)
Lab (CF 162)
Office hours

Scott (CF 471 or remote by appointment):

Arun (CF 163):

Ryan (CF 163):

Synopsis from the WWU Course Catalog

Introduction to discrete structures important to computer science, including sets, trees, functions, and relations. Proof techniques. Introduction to the formal language classes and their machines, including regular languages and finite automata, context free languages and pushdown automata. Turing machines and computability will be introduced. Programming using a functional language is required in the implementation of concepts. Includes lab.

Course Outcomes

Upon completion of this course, students will demonstrate:

  1. Thorough understanding of the mathematical definitions of concepts important to computer science, including sets, tuples, lists, strings, formal languages, functions and relations.
  2. The ability to prove basic theorems involving these mathematical concepts including proofs by contradiction and inductive proof
  3. The ability to employ effectively the functional programming style in a functional programming language
  4. Solid understanding of the Chomsky hierarchy, including regular and context free languages, and their corresponding accepting machines and describing grammars
  5. Basic understanding of Turing machines and computability
  6. Basic understanding of important algorithms, including conversion of finite automata to different forms, conversion of grammars to machines
  7. Basic understanding of LL(k) and LR(K) grammars and the parsing techniques used for LL(1) grammars
Huh?

This course is a bit of a grab-bag that introduces several components of the more theoretical side of computer science. It has three major components: (1) discrete math, logic, and proof; (2) formal languages and automata theory; and (3) functional programming. Here’s a little more on what each of these is about:

Textbooks

The required books for this course are all freely available online in digital form:

Schedule

Below is a tentative schedule that will be updated to reflect reality as the quarter progresses. Lecture materials, assignments, labs and other materials will also be posted here.

Week Lecture Date Topics Lab HW (due) Readings
0 0 9/25 Sets 0, Racket 0
notes, ws, wb
TS 1-2; BP 1
1 9/27 Sets 1
notes, ws, wb
1 2 9/30 Racket 1
notes, ws, code
TS 3-6; BP 1-2
3 10/1 Racket 2
notes, ws, code, wb
Lab 1
tests
4 10/2 Sets 2
notes, ws, wb
5 10/4 Logic 1
notes, ws, wb
A1 pdf, tex
(due 10/6)
2 6 10/7 Logic 2
notes, ws, wb
TS 6; BP 2-3
7 10/8 Logic 3
notes, ws, template, wb
Lab 2
tests
8 10/9 No class - Sick Day
Read Book of Proof 2.8-2.12
BP 2.8-2.12
9 10/11 Logic 4; Introduction to proofs
notes, ws, wb, equivalences
BP 4
3 10 10/14 Direct Proof
notes, ws, wb
BP 4
11 10/15 No class - Sick Day Lab 3
tests
BP 5
12 10/16 Contrapositive Proof
notes, ws, wb
A2 pdf, tex BP 5
13 10/18 Proof by contradiction
notes, ws, wb
BP 6
4 14 10/21 Proving Non-Conditional Statements
Disproof
notes, ws, wb
BP 7, 9
15 10/22 Proofs Involving Sets
notes, ws, wb
Lab 4
tests
BP 8
16 10/23 Induction 1
notes, ws, wb
A3 pdf, tex BP 10
17 10/25 Induction 2
notes, ws, wb
BP 10
5 18 10/28 Relations
notes, ws, wb
BP 11
19 10/29 Relations, Functions
notes, ws, wb
Lab 5
tests
BP 12
20 10/30 Functions
notes, ws, wb
A4 pdf, tex BP 12
11/1 Midterm Exam
study guide, racket practice
exam wrapper
6 21 11/4 Theory of Computation: Intro
notes, wb
TC 1-2
22 11/5 Finite Automata, DFAs
notes, ws, wb
Lab 6
tests
TC 2
23 11/6 DFAs and Regular Languages
notes, ws, wb
A5 pdf, tex TC 2
24 11/8 NFAs
notes, ws, wb
TC 2
7 11/11 Veteran’s day (M)
TC 2
25 11/12 NFA to DFA, Regular Closure
notes, ws, wb
Lab 7
tests
TC 2
26 11/13 Regular Closure, Regular Expressions
notes, ws, wb
TC 2
27 11/15 Context-Free Grammars
notes, ws, wb
A6 pdf, tex TC 3
8 28 11/18 Parsing, Grammar Transformations
notes, ws, wb
TC 3
Formal Grammars
Top-Down parsing
29 11/19 LL(1) Parsing - 1
notes, ws, wb
No Lab;
Ryan OH 10-12
30 11/20 LL(1) Parsing - 2
notes, ws, wb
rpn-LL.rkt, rpn-ast.rkt
A7 pdf, tex
31 11/22 Pushdown Automata
9 32 11/25 CFG to PDA TC 4
33 11/26 The Pumping Lemma - Regular and CF Lab 8 A8 (due Wednesday)
Thanksgiving Break
Thanksgiving Break
10 12/2-6 Turing Machines; Review A9 (due Wednesday) TC 4-5
Monday 12/9 Final Exam 8:00am - 10:00am

Assessment

Grade Breakdown

Grades will be calculated as a weighted average of scores on the following course components, each of which is described in more detail below:

Final letter grades will be computed as follows:

(define grade
  (lambda (pct)
    (cond ((> pct 0.90) #\A)
          ((> pct 0.80) #\B)
          ((> pct 0.70) #\C)
          ((> pct 0.60) #\D)
          (else         #\F))))

The calculated raw percentages may be curved nonlinearly at the instructor’s discretion, but any such curve used will not reduce anyone’s grade. “+” or “-” cutoffs will be decided at the instructor’s discretion.

Labs

The weekly labs will develop your abilities as a programmer in the functional programming style using the Racket language, which is (as Wikipedia puts it) a modern dialect of Lisp, and a descendent of Scheme. In labs 1 and 2, you will solve some short programming exercises to familiarize yourself with the language. In Labs 3 through 8, you will cumulatively build up a complete (though not fully-featured) interpreter for the Racket language, written in Racket itself.

These are the only programming assignments in the course, and I anticipate that most students will need to spend time outside the lab period to complete them. Labs for both sections take place on Tuesdays, and the submission deadline is the Sunday following the lab period each lab was assigned. Per the tentative schedule, the eight labs will be assigned in (zero-indexed, with the first partial week being week 0) weeks 1 through 8 of the course.

To get full credit for a lab activity, you must both attend lab and hand in the deliverable by the deadline, which will typically be 10:00pm on the Sunday following the lab period. Attending a lab section other than the one you are registered for requires permission from both me and both lab TAs. If you do not attend lab but do submit the deliverable on time you will receive half credit (i.e., your score will be multiplied by 0.5). This non-attendance penalty is automatically waived for one lab; if you have a legitimate reason for missing additional labs, contact me ahead of time.

Written Homework

Written homeworks will be assigned weekly; details will be provided on the Schedule table and Canvas above. You may submit a revised version for regrading up to a week after initial feedback is released. To have your submission regraded, you need to email me and the grader to let us know. No additional credit will be given for revisions on a problem if the original submission did not contain an honest effort at a solution.

You will write your assignment solutions in LaTeX, using a template document provided for each assignment. Information on getting started with LaTeX can be found in this guide.

Midterm Exam

The midterm exam will be taken in-class. The tentative date for the midterm is Friday, November 1st. More details on content, format, etc. will be provided no less than a week before the exam. You will be allowed to use one double-sided 8.5x11 sheet of handwritten notes.

Final Exam

The final exam will be held in our usual classroom on Monday, 12/9 from 8:00am to 10:00am. More details on content, format, etc. will be provided no less than a week before the exam. The final exam will be cumulative. You will be allowed to use two double-sided 8.5x11 sheets of handwritten notes.

If your final exam grade exceeds your midterm exam grade, then your midterm exam grade will be replaced by your final exam grade in the calculation of your final grade. In other words, the total exam contribution your final grade in the course will be \[ \begin{align*} \max(&\\ &0.2*\textrm{midterm} + 0.2*\textrm{final}, \\&0.4 * \textrm{final}\\ )& \end{align*} \] Please note that this calculation cannot be implemented in the Canvas gradebook, so you will not see it there but it will be applied when determining your final grade. This policy does not apply if you did not take the midterm exam.

I do not release final exams or final exam grades. This means that at the end of the quarter, your score on Canvas will not reflect your final grade in the course. If you wish to see your final exam, you can review your final exam in-person in my office starting at the beginning of the following quarter by visiting my office hours or emailing me to make an appointment. Per the University Academic Policies, a student who fails to take a final examination without making prior arrangements acceptable to the instructor receives a failing grade for the course.

Other, including class participation, surveys, etc.

Your grade in this category will primarily be determined by your attendance and participation in in-class learning activities; it will also include feedback surveys and potentially other miscellaneous assessment items. No items in this category are graded for correctness, and no penalty will be applied to your grade as a result of missing four or fewer class periods.

Logistics

Course Webpage / Syllabus

The Schedule section of this page will be updated as the quarter progresses with daily topics and links to lecture materials and assignments. I suggest bookmarking this page (including the #schedule at the end will link you straight to that part of the page); if you forget the URL and need to find your way back here, you can use link on the Syllabus page in Canvas.

Computer Labs

The CS department maintains a set of Computer Science computer labs separate from the general university labs. These systems are all set up with the software that you need to complete the work for this class.

Lab Locations and Access
The following rooms in Communications Facility are CS Department labs: 162, 164, 165, 167, 405, 418, 420. These labs are open to all CS students (that’s you!) any time except when scheduled for a class or other activity. The complete list of CS labs and their schedules can be found on the CS Support documentation. CF 405 is never booked, so it’s always available. Labs are open 24/7, although the building locks at 11pm so you won’t be able to enter later than that.

Canvas

We will use Canvas for announcements, grades, and submission of assignments. Lab and homework assignment write-ups will be linked from both the course webpage and the corresponding assignment on Canvas. Lecture materials, handouts, readings, etc. will be posted on the course webpage only.

Feedback

I take student feedback seriously. I appreciate any feedback you’re willing to give, and I will do my best to act on constructive feedback when possible. I will solicit feedback formally partway through the course, but you are welcome to provide feedback at any time in my office hours, by email, or if you desire anonymity you can use this Google Form.

Discord

The course Discord server is a good way to interact with your classmates and ask questions. You can find the server invite link on the Syllabus page on Canvas. I try to check the q-and-a channel regularly and answer questions when possible, but I also hope that classmates will also be able to step in and answer questions before I get to them.

Discord is not the place to get help that requires viewing of code, nor is it the place for “official” course communication. A couple points of Discord etiquette that I will require for this class:

Resources for Getting Help and Support

Help with Course Content

If you are stuck, struggling, or need help on any aspect of the course, you have several avenues for seeking help, and I hope that you will use them:

Other Resources

Faculty Community Ambassadors

The Computer Science department has Faculty community ambassadors. The role of these ambassadors is to hear concerns, feedback, or questions from students, faculty and staff, especially (but not limited to) those related to equity, inclusion and diversity issues. We hope that the Community Ambassadors can advise and also guide people to college, university or external resources.

Our current Faculty Community Ambassadors are Yudong Liu and myself (Scott Wehrwein). You can find more information on Commnity Ambassadors and contact details for both at the following link: https://cs.wwu.edu/diversity-equity-inclusion.

University Resources

As a reminder, the following University resources are always available:

Course Policies

Professionalism

I am committed to maintaining an inclusive, supportive, and professional environment in all academic settings including lectures, labs, and course-related online spaces. Students are expected to live up to the ACM Code of Ethics and Professional Conduct. This is the ethical code adopted by nearly every software professional. Failing to follow the ACM Code of Ethics and Professional Conduct can negatively affect course grades up to and including a failing grade for the course.

Attendance

As described above in the Assessment section, you are expected to attend both class and lab. Up to four absences from class will not affect your grade; additional absences will cause deductions on the in-class portion of your grade. For labs, the 50% absence penalty will be waived for one lab. If you have reasons that you need to miss class or lab beyond these limits, please talk to me about case-by-case exceptions.

Late Work

Written Homeworks

You have three “slip days” that you may use at your discretion to submit written homework assignments late. Slip days apply only to written homework assignments and cannot be applied to any other deadline, including labs. You may use slip days one at a time or together - for example, you might submit each of three assignments one day late, or submit one assignment three days late. A slip day moves the deadline by exactly 24 hours from the original deadline; if you go beyond this, you will need to use a second slip day, if available.

After your slip days are exhausted, a penalty of 10% * floor(hours_late/24 + 1) - that is, 10% per day late unless you have made prior arrangements with me.

You do not need to contact me to let me know that you are using a slip day; slip days will be applied automatically based on Canvas submission timestamps.

Labs

Lab deadlines are firm because, starting with lab 3, each week’s lab depends on the prior one. Labs are due Sunday night the week they are assigned. There is a one-day grace period until Monday night during which lab submissions will be accepted without penalty; after this, no late lab submissions will be accepted.

Communication Guidelines

Announcements

I will make all course-related announcements either in class or on Canvas. In-class announcements will be posted on the Schedule table on the course webpage. It is your responsibility to make sure that you see Canvas announcements promptly and check the in-class announcements if you miss class. Canvas should be configured to send you an email notification by default, but if you are unsure, please come see me in office hours.

Email

Email is the best way to get in touch with me. I do my best to check email regularly and respond when I can, but I am not able to be instantly responsive all the time. If you have something time-sensitive, email is the medium that I am most likely to see first. You can use Canvas messages as an alternative; these simply go to my email.

Grace

The policies for this course have “grace” built in for most categories of assignments: you have slip days for assignments, at least four missed classes without penalty, and the opportunity to override your midterm exam grade with your final exam grade.

If any of the above forms of “grace” apply to your situation, you do not need to contact me: the grace policies are applied automatically. If you have extenuating circumstances that have caused or will cause you to go beyond the allowed grace, please contact me by email or in person to explain your situation.

Canvas Submission Comments

I do not read Canvas submission comments, so please do not use them. If you have a message for me and/or the TAs, please use email instead.

See Me After Class

Many quick questions can be resolved in a timely fashion by talking to me after class instead of using email or waiting for office hours. I will be available in the 10 minutes following lecture, so please feel free to use this time.

Academic Honesty

Collaboration Policy

Lab and written assignments are to be completed independently. Students are welcome to discuss assignments with each other on a conceptual level, but each student should be writing their solution independently. Sharing your solution with others or looking at someone else’s solution is an explicit violation of this collaboration policy. To make sure you are collaborating appropriately, follow these two rules:

Automated tools will be used to check your code for plagiarism. They are invariant to simple strategies such as changing variable naming and whitespace; in fact, changing code enough to eliminate the appearance of plagiarism is usually harder than doing the assignment.

For written homework, the above ideas apply similarly - you are free to discuss problem solving approaches, sketch out proofs, etc. at a whiteboard, but take a break before sitting down to write up your solutions.

On The Use of AI Tools

AI tools such as ChatGPT and Github Copilot raise significant, new, and unanswered questions about their role in education, and indeed in the work your education is likely preparing you for. No one knows what this means for the future!

This policy is subject to change. The use of generative AI tools is allowed with two conditions:

  1. You are making a genuine effort to use AI as a learning tool.
  2. You submit a transcript of your interactions alongside the assignment you used it for.

This policy is subject to change. Exams will be closed-book, so generative AI tools will not be available to you.

Changes to the Syllabus

This syllabus is subject to change. Changes, if any, will be announced in class or online. Students will be held responsible for all changes.

University Policies

All University-wide policies apply to this course, including those outlined at http://syllabi.wwu.edu. These policies cover issues including:

Acknowledgements

I’m grateful to Aran Clauson, Yudong Liu, and Selina Akter for generously sharing materials for this course.