CS 6371: Advanced Programming Languages

Course Information

Title: CS 6371: Advanced Programming Languages
Course Registration Number: 24620/003641
Times: TR 1:00–2:15
Location: FO 1.202
Instructor: Dr. Kevin Hamlen (hamlen AT utdallas)
Instructor's Office Hours: TR 2:30–3:30 (ECSS 3.704)
Teaching Assistant: Shreya Soman
TA Office Hours: Thu 11:30–1:00 (ECSS 3.612)

Course Summary

This course covers functional and logic programming, concepts of programming language design, and formal reasoning about programs and programming languages. The following are the course learning objectives:

  1. Theory and practice of Functional Programming (ML/OCaml): Students will learn the mathematical foundations and practice of implementing software in a functional programming style that leverages recursion and list-folding for loops, and immutable variables for program state.
  2. Theory and practice of Logic programming (Prolog): Students will learn the mathematical foundations and practice of implementing search-based algorithms using a logic programming style that leverages backtracking and term unification to make progress through a search space.
  3. Small-step and large-step operational semantics: Students will learn how to reason mathematically about computer programs using deductive logic extended with computational axioms.
  4. Denotational semantics: Students will learn how to reason mathematically about computer programs using sets and functions.
  5. Fixpoint theory: Students will learn the mathematical foundations of reasoning about loops in programs, including lattice theory, complete partial orders, and fixpoints.
  6. Axiomatic semantics: Students will learn how to formally reason about high assurance systems using Hoare Logic and its mathematical foundations.
  7. Type theory (simple, higher-order, and lambda cube): Students will learn how to extend type systems for programming languages to enable more powerful reasoning and higher assurance through higher-order (non-simple) types.
  8. Untyped and typed lambda calculi: Students will learn how to encode functions and simple types as the mathematics of the lambda calculus, and use it to reason about functional programs.
  9. Partial evaluation, non-determinism: Students will learn to leverage the types and semantics of first-class functions to reduce code bloat and write high assurance software, and improve robustness of non-deterministic, concurrent code.

Through taking this course, students will learn the tradeoffs of imperative vs. non-imperative programming languages, issues involved in designing a programming language, the role of formal semantics and type-systems in reasoning about programs and languages, and proof techniques related to formal, high-assurance software validation.

The course is open to Ph.D. students and Masters students. Interested undergraduates should see the instructor for permission to take the course.

Prerequisites: Algorithm Analysis and Data Structures (CS 3345/5343 or equivalent), Automata Theory (CS 4384/5349 or equivalent). A solid background in each of these areas will be heavily assumed throughout the course!

CLO Comparison with CS 4301

CS 6371 is cross-listed with an undergraduate-level course numbered CS 4301, which has reduced course learning objectives (CLOs). Students enrolled in CS 4301 are not responsible for or assessed on the additional CLOs specific to CS 6371. Here are how the CS 6371 CLOs differ from the ones for CS 4301:

  1. Theory of Functional Programming (ML/OCaml): Students of CS 6371 will additionally learn the mathematical foundations of functional programming, including System F, lambda cube, and higher-order dependent type theory. Homework and exam questions on these subjects are not assigned to CS 4301 students.
  2. Theory of Logic programming (Prolog): Students of CS 6371 will additionally learn the mathematical foundations of search-based logic programming. Homework and exam questions on these subjects are not assigned to CS 4301 students.
  3. Small-step and large-step operational semantics: This CLO is the same for CS 4301 and CS 6371 students.
  4. Denotational semantics: This CLO is the same for CS 4301 and CS 6371 students.
  5. Fixpoint theory: Students of CS 6371 will additionally learn the mathematical foundations of reasoning about loops in programs, including lattice theory, complete partial orders, and fixpoints. Students of CS 4301 will not receive homework assignments or exam questions on this subject.
  6. Axiomatic semantics: This CLO is the same between CS 4301 and CS 6371.
  7. Type theory: Students of CS 6371 will additionally learn how to extend type systems for programming languages to enable more powerful reasoning and higher assurance through higher-order (non-simple) types. Homework and exam questions on these subjects are not assigned to CS 4301 students.
  8. Untyped and typed lambda calculi: Students of CS 6371 will additionally learn higher-order lambda calculi. Homework and exam questions on these subjects are not assigned to CS 4301 students.
  9. Partial evaluation, non-determinism: Students of CS 6371 will additionally learn to leverage the types and semantics of first-class functions to improve robustness of non-deterministic, concurrent code. Homework and exam questions on these subjects are not assigned to CS 4301 students.

To Prepare for the Course...

The first three classes are extremely important for succeeding in the remainder of the course; students are therefore urged to participate in the course from the start, by attending the first three classes in person. These initial classes will cover functional programming in the OCaml programming language, which will introduce many concepts assumed throughout the rest of the course. As mandated by the CS Dept Attendance Policy, missing the first 3 classes will result in an automatic deduction of one letter grade, and missing the first 4 classes will result in an automatic failing grade for the course.

To better understand the in-class OCaml demos, you should do the following as preparation:

Using OCaml from the UTD Server

If you can't get OCaml to work on your personal machine, you can use OCaml on the UTD CS Department Linux servers. To do so:

Grading

Homework (25%): Homeworks will be assigned approximately once per 1.5 weeks, and will consist of a mix of programming assignments and written assignments. Programming assignments will be implemented in OCaml or Prolog. Written assignments will typically involve discrete math proofs. Homeworks must be turned in at the start of class (i.e., by 1:05pm) on the due date. To help students prepare for the next assignment, homework solutions will typically be revealed on each due date. Therefore, no late homeworks will be accepted.

Quizzes (15%): On indicated assignment due dates (see the course schedule below), students will solve one or two problems individually at the start of class as a quiz. The quiz problems are essentially extra homework problems solved individually in class without the help of the internet or collaboration with other students. The quizzes will be closed-book and closed-notes.

Midterm (25%): There will be an in-class midterm exam in class on Thursday, March 9th. The exam will cover functional programming, operational semantics, denotational semantics, and fixpoints.

Final (35%): A final exam for the course will be scheduled by the university registrar. The exam will be cumulative, covering all material in the course. Students will have 2 hours and 45 minutes to complete it.

Homework Policy

Students may work individually or together with other students presently enrolled in the class to complete the assignments, but they must CITE ALL COLLABORATORS AND ANY OTHER SOURCES OF MATERIAL that they consulted, even if those sources weren't copied word-for-word. Copying or paraphrasing someone else's work without citing it is plagiarism, and may result in severe penalties such as an immediate failing grade for the course and/or expulsion from the computer science program. Therefore, please cite all sources!

Students may NOT consult solution sets from previous semesters of this course, or collaborate with students who have such solutions. These sources are off-limits because such "collaborations" tend to involve simply copying or reverse-engineering someone else's answer to a similar homework problem, which does not prepare you for the quizzes and exams.

Texts

The course has no required textbook, but we will make use of several online references:

Tentative Course Schedule

Date Topic Assignments
Functional Programming
Lecture 1:
Tue 1/20
Course Introduction: Functional vs. Imperative programming, type-safe languages, intro to OCaml
Lecture Slides
OCaml Transcript
Assignment 1 due 2/5
(Functional Programming)
Lecture 2:
Thu 1/22
OCaml: Parametric polymorphism
OCaml Transcript
Lecture 3:
Tue 1/27
Canceled: Weather emergency
Lecture 4:
Thu 1/29 (recorded on Teams due to weather emergency)
OCaml: List folding, tail recursion, exception-handling
Operational Semantics
Lecture 5:
Tue 2/3
Large-step Semantics: Intro
Lecture Slides
Assignment 2 due 2/10
(SIMPL Interpreter)
Lecture 6:
Thu 2/5
Large-step Semantics: Structural induction
Lecture Slides
Supplementary Lecture Notes
Lecture 7:
Tue 2/10
Small-step Semantics
Lecture Slides
Small-step Semantics Reference
Quiz #1: OCaml Programming
Assignment 3 due 2/19
(Operational Semantics)
Denotational Semantics
Lecture 8:
Thu 2/12
Denotational Semantics: Semantic domains and valuation functions
Lecture Slides
Denotational Semantics Reference
Lecture 9:
Tue 2/17
Denotational Semantics: Fixpoints
Lecture Slides
Notes on Complete Partial Orders
Lecture 10:
Thu 2/19
Fixed-point Induction
Lecture Slides
Quiz #2: Operational Semantics
Assignment 4 due 3/5
(Denotational Semantics)
Lecture 11:
Tue 2/24
Program-proof Co-development: Intro to Rocq
See Teams recording for Rocq transcript.
Fixpoint Induction Examples
Lecture 12:
Thu 2/26
Semantic Equivalence
Lecture Slides
Lecture 13:
Tue 3/3
Proof Automation
Rocq Proof of Semantic Equivalence
Type Theory
Lecture 14:
Thu 3/5
Type Theory: Static Semantics
Lecture Slides
Quiz #3: Denotational Semantics
Assignment 5 due 3/24
(SIMPL Type-checker)
Lecture 15:
Tue 3/10
Midterm Review
Sample Midterm Exam w/Solutions
Midterm:
Thu 3/12
Midterm Exam
No Class:
Tue 3/17
No Class: Spring break
No Class:
Thu 3/19
No Class: Spring break
Untyped & Simply-typed Lambda Calculus
Lecture 16:
Tue 3/24
Untyped Lambda Calculus: History, Semantics, Completeness
Lecture Slides
Assignment 6 due 4/2
(Lambda calculus)
Lecture 17:
Thu 3/26
Type Safety: Progress, Preservation, Subtyping
Quiz #4: Type Theory
Lecture Slides
Lecture Notes on Type Safety
Rocq Proof of Type Safety
Logic Programming
Lecture 18:
Tue 3/31
Logic Programming: Part I
Lecture Slides
Lecture 19:
Thu 4/2
Logic Programming: Part II
Lecture Slides
Quiz #5: Lambda Calculus
Assignment 7 due 4/14
(Prolog)
Lecture 20:
Tue 4/7
Logic Programming: Part III
Lecture Slides
System F
Lecture 21:
Thu 4/9
System F: Syntax & Sematics
Lecture Slides
Lecture 22:
Tue 4/14
Curry-Howard Isomorphism: Type-inhabitation
Lecture Slides
Quiz #6: Prolog
Assignment 8 due 4/28
(Functional SIMPL)
Lecture 23:
Thu 4/16
Summary/Comparison of Modern Language Features: Hindley-Milner type-inference, type polymorphism
Lecture Slides
Lecture Notes
Lecture 24:
Tue 4/21
Summary/Comparison of Modern Language Features: Weak vs. strong typing, type-safety, function evaluation strategies
Lecture Slides
Formal Verification
Lecture 25:
Thu 4/23
Axiomatic Semantics: Hoare Logic
Lecture Slides
C.A.R. Hoare's original 1969 paper on Axiomatic Semantics (optional reading)
Lecture 26:
Tue 4/28
Axiomatic Semantics: Loop invariants
Lecture Slides
Assignment 9 due 5/7
(Axiomatic Semantics)
Lecture 27:
Thu 4/31
Axiomatic Semantics: Weakest precondition, strongest postcondition
Lecture Slides
Lecture 28:
Tue 5/5
Final Review
Lecture Slides
Sample Final Exam Questions w/Solutions
Lecture 29:
Thu 5/7
Final Review
Lecture Slides
Quiz #7: Axiomatic Semantics
Final Exam
Tue 5/12 2:00–4:45pm
ECSS 2.203