CS 138: Automata and Formal Languages (Spring '18)

[Annnouncements] [General Info] [Team] [Weekly Schedule] [Textbook] [Piazza] [Grading] [Schedule and Homework] [Links]


  • April 2: Please sign into the Piazza page as soon as possible.

General information

  • Total credits: 4
  • Topics: Formal languages; finite automata and regular expressions; properties of regular languages; pushdown automata and context-free grammars; properties of context-free languages; introduction to computability and unsolvability (Turing machines) and computational complexity.
  • Prerequisites: Computer Science 40 with a grade of C or better; open to computer science and computer engineering majors only.


Instructor: Stefano Tessaro, tessaro@cs, Harold Frank Hall 1117

Teaching assistants

  • Burak Kadron (kadron@cs)
  • Magzhan Zholbaryssov (magzhan@cs)


  • Mohith Pukale (mohithpukale@cs)

Weekly schedule

  • Class time and location
    Mon and Wed 2:00-3:15pm (South Hall 1431)
  • Discussion sections
    Fri 9-9:50am (Phelps 2516)
    Fri 10-10:50am (GIRV 1116)
  • Office hours
    ST: Tue 4:30-5:30p or by appointment (HFH 1117)
    Burak: Mon 3:30-5:30p (Trailer 936 Room 104)
    Magzhan: Thu 3:30-5:30p (Trailer 936 Room 104)


We will be using the (recommended) textbook: Peter Linz, An Introduction to Formal Languages and Automata, Jones and Bartlett Learning.

While we will not force you to buy it, it will be helpful if you get your hands on a copy. We will post pages covering materials from the class, and the notation will be (largely) consistent.


We are going to use Piazza for discussions about this class, i.e., we are going to only use the Q&A session for now: https://piazza.com/ucsb/spring2018/cs138/home (and enroll here!)

Performance Assessment

  • Homework: There will be 8 problem sets distributed over the quarter. Generally, problem sets are posted online on Monday, by 11:59pm PST, and are due 9 days later on Wednesday, 2pm PST (use the homework box in the CS mail room for submission, or subit at the beginning of class at 2pm.) Homework will be graded, and will constitute an important part of the grade. An exception is Homework 4.5, which will serve the purpose to refresh some concepts before the midterm.
  • Midterm: There will be one midterm on Wednesday, May 2, 2018. Allowed are only two letter-size sheets of handwritten notes. (Four pages.)
  • Final: The final will take place on Monday, June 11, 4-7pm . Allowed are only four letter-size sheets of handwritten notes. (Eight pages.)
  • Final grade: The final grade will be made by the homework (30%), midterm (25%), and final (45%). The lowest homework grade will be dropped.
  • Academic Honesty: The following applies to every course you attend at UC Santa Barbara (from UCSB Campus Regulations, Chapter VII: "Student Conduct and Discipline"):

    It is expected that students attending the University of California understand and subscribe to the ideal of academic integrity, and are willing to bear individual responsibility for their work. Any work (written or otherwise) submitted to fulfill an academic requirement must represent a student’s original work. Any act of academic dishonesty, such as cheating or plagiarism, will subject a person to University disciplinary action. Using or attempting to use materials, information, study aids, or commercial “research” services not authorized by the instructor of the course constitutes cheating. Representing the words, ideas, or concepts of another person without appropriate attribution is plagiarism. Whenever another person’s written work is utilized, whether it be a single phrase or longer, quotation marks must be used and sources cited. Paraphrasing another’s work, i.e., borrowing the ideas or concepts and putting them into one’s “own” words, must also be acknowledged. Although a person’s state of mind and intention will be considered in determining the University response to an act of academic dishonesty, this in no way lessens the responsibility of the student.

    Specifically for the current CS138 course this means that
    • You are not allowed to copy or transcribe answers to homework assignments from others or other sources.
    • Although you are allowed to discuss homework assignments with others, you should write down your answers independently. You should always be able to argue and explain your answers when asked for clarifications.
    • During the Midterm and Final Examination no electronics are allowed, additional notes are only allowed to the extent described prior to the test.
    • When you will be unable to hand in the homework in time you should report this to the lecturer (ST) as soon as possible, but always before the deadline. No matter the reason, you will always be asked to present documentation.
    • When in doubt, ask.
    Students violating the rules of Academic Honesty will receive an "F" for the course and will be reported to the Dean of Students Office.

Schedule and Homework

The following is a tentative schedule, and is intended to give a rough idea about what I hope to cover in the class and in which order. There will be (slight) changes depending on the pace of the class, and more information will appear on the schedule.

WeekDate Lecture contents Reading Assignments
1 2018-04-02 Welcome to CS138
  • Course organization
  • Why is this class important?
  • Review of basic mathematical language
  • Strings and languages
  • L pp 1-20
2018-04-04 Regular languages and DFAs
  • Brief interoduction to regular expressions
  • Definition of DFAs and extensive example
  • Definition of regular languages
  • L pp 37-49
2 2018-04-09 From DFAs to NFAs
  • The complement of a regular language is regular
  • More DFA examples, and difficulty of union
  • Definition of NFAs
  • Examples of NFAs
  • L pp 49-56
2018-04-11 Equivalence of DFAs and NFAs
  • Building a DFA from an NFA
  • A few words on DFA minimization
  • L pp 56-69
  • HW1 due
3 2018-04-16 Regular expressions
  • RegExp Definition
  • Language defined by a RegExp
  • RegExps exactly describe regular languages
  • Closure properties
  • L pp 71-89
  • L pp 99-109
2018-04-18 Non-regular languages and the Pumping Lemma
  • A direct proof of non-regularity
  • The Pumping Lemma and Applications
  • L pp 114-124
  • HW2 due
4 2018-04-23 From regular languages to grammars
  • The Myhill-Nerode Theorem
  • Right- and left-regular grammars
  • Equivalence of right and left-regular grammars and regular languages
  • L pp 89-97
2018-04-25 Regular languages wrap-up
  • Mealy machines
  • Moore machines
  • Equivalence of Mealy and Moore machines
  • Format-transforming encryption and regular languages
  • L Appendix A
  • HW3 due
5 2018-04-30 Context-free grammars and languages
  • Definition of CFGs / CFLs and linear grammars
  • Examples
  • Left-most and right-most derivations
  • Derivation trees
  • Ambiguity
  • L pp 125-145
2018-05-02 MIDTERM
  • HW4 due
6 2018-05-07 Simplifying context-free grammars I
  • Basic simplifications
  • Removing useless productions
  • Removing lambda productions
  • L pp 149-158
2018-05-09 Normal forms and parsing
  • Removing unit productions
  • Chomsky normal form
  • Greibach normal form
  • The parsing problem
  • Brute-force parsing
  • L pp 158-169
  • L pp 136-140
7 2018-05-14 Parsing and pushdown automata
  • The CYK algorithm
  • Simple grammars
  • LL(k) grammars
  • Introduction to NPDAs
  • L pp 171-172
  • L pp 201-204
  • L pp 175-182
2018-05-16 Pushdown automata and the pumping lemma
  • Equivalence of NPDAs and CFLs
  • Deterministic PDAs
  • L pp 175-201
  • HW5 due
8 2018-05-21 Turing Machines
  • Pumping Lemma for CFLs
  • Turing Machines: Definition and examples
  • Recursively enumerable and recursive languages
  • L pp 205-210
  • L pp 223-245
2018-05-23 Computability I
  • Review: Countable and uncountable sets
  • Recursively enumerable languages are countable (and so are TMs)
  • Existence of languages which are not RE
  • Existence of languages which are RE, but not recursive
  • HW6 due
9 2018-05-28 No class - Memorial Day
2018-05-30 Computability II
  • The Halting Problem is undecidable
  • Computer viruses and undecidability
  • The Post Correspondence Problem (PCP)
  • Undecidability of PCP
  • HW7 due
10 2018-06-04 Computability III
  • CFGs and undecidability
  • Deciding ambiguity is undecidable
  • Turing Computability
  • Multi-Tape TMs
  • Non-deterministic TMs
2016-06-06 Introduction to computational complexity + Wrap Up
  • HW8 due


The following are some links relevant to this class: