Type of Credit: Elective
Credit(s)
Number of Students
As software systems become increasingly critical to infrastructure, finance, and security, the ability to write code that is not just "functional" but provably correct is a defining skill for advanced computer scientists.
This course moves beyond standard software engineering practices to explore the mathematical and logical foundations of programming. We bridge the gap between implementation (writing code that runs) and specification (describing what code should do). The curriculum is divided into three interconnected pillars:
Functional Programming (TypeScript): We begin by disciplining state and side effects using strong static typing, algebraic data types, and monads.
Constraint Programming (Z3/SMT): We treat logic as a computational tool, using SAT/SMT solvers to model complex problems and synthesize solutions automatically.
Program Verification (Dafny): We culminate by combining programming and logic to write mathematically verified software, where the compiler guarantees correctness against a formal specification.
By the end of this semester, students will be able to:
Reason about correctness: Move beyond "testing cases" to proving properties for all possible inputs.
Leverage type systems: Use advanced type theory (generics, ADTs) to make invalid states unrepresentable.
Model problems logically: Translate real-world resource and scheduling constraints into First-Order Logic for automated solving.
Verify algorithms: Use Hoare Logic and pre/post-conditions to mathematically prove the correctness of imperative algorithms.
Discrete Mathematics: Comfort with Boolean logic, set theory, and basic proof techniques (induction).
Data Structures: Familiarity with trees, graphs, and standard algorithms (sorting/searching).
Programming Maturity: Ability to write non-trivial programs.
能力項目說明
Upon successful completion of this course, students will be able to:
Formalize Software Behavior: Translate informal English requirements into rigorous mathematical specifications using First-Order Logic and Type Theory.
Construct Robust Architectures: Apply advanced functional programming patterns, including Algebraic Data Types and Monads, to design software where invalid states are unrepresentable by the type system.
Solve Constraints Automatically: Model complex decision and optimization problems (e.g., scheduling, layout) as satisfiability formulas and utilize SMT solvers (Z3) to find solutions or prove unsatisfiability.
Verify Imperative Algorithms: Use Hoare Logic to annotate programs with preconditions, postconditions, and loop invariants, and successfully verify their total correctness using the Dafny verifier.
Reason About Program State: Distinguish between distinct notions of correctness (e.g., structural (types), logical (constraints), and behavioral (formal verification)) and select the appropriate formal method for a given software assurance challenge.
|
Week |
Module |
Topic |
Key Concepts & Activities |
|
1 |
Part 1: Functional Programming |
Foundations |
Theory: Lambda calculus Practice: Combinators |
|
2 |
Algebraic Data Types |
Theory: Recursion, induction, and co-induction Practice: Data structures |
|
|
3 |
Higher-Order Abstractions |
Theory: Parametricity and free theorems Practice: Code refactoring |
|
|
4 |
The Algebra of Programming |
Theory: Category theory Practice: Handling side effects via Monads |
|
|
5 |
Part 2: Constraint Programming |
Propositional Logic & SAT |
Theory: Propositional logic Tool: SMTLIB / Z3 Python Practice: Solving logic puzzles |
|
6 |
SMT (Satisfiability Modulo Theories) |
Theory: First-order logic and theories Practice: Modeling resource allocation/scheduling |
|
|
7 |
Holiday |
||
|
8 |
Part 2: Constraint Programming |
Symbolic Execution |
Theory: Modeling program paths as logic formulas Practice: Generating test inputs, proving function equivalence |
|
9 |
Advanced Constraints & Synthesis |
Theory: Syntax-guided synthesis (SyGuS) Practice: Synthesizing coefficients/guard conditions |
|
|
10 |
Midterm Exam |
A poll will decide the date. |
Format: Hands-on exam Coverage: Problem-solving using FP and CP |
|
11 |
Part 3: Program Verification |
Hoare Logic & Contracts |
Theory: Hoare triples, weakest preconditions Tool: Dafny Practice: Programming with Contracts |
|
12 |
Deductive Verification |
Theory: Compositional verification, framing Practice: Verifying math functions |
|
|
13 |
Deductive Verification |
Theory: Loop invariants and variants Practice: Verifying combinatorial algorithms |
|
|
14 |
Deductive Verification |
Theory: Predicate transformers, data consistency Practice: Verifying common data structures |
|
|
15 |
Final Exam |
Format: Hands-on exam Coverage: Symbolic execution, program verification |
|
|
16 |
Presentations |
Present articles in the reading list |
| Component | Weight | Description |
| Class Participation | 10% | Engagement in workshops, in-class coding exercises, and discussions. |
| Midterm Exam | 30% | Hands-on exam covering Functional Programming and Logic (Weeks 1–8). |
| Final Exam | 30% | Hands-on exam with emphasis on Program Verification (Weeks 1–16). |
| Presentation | 30% | Presentation based on articles in the reading list |
Structure and Interpretation of Computer Programs by Abelson, Harold, Sussman, Gerald Jay, Henz, Martin (Summit Valley Press 2022)
Program Proofs by K. Rustan M. Leino (MIT Press, 2023):
JavaScript: the First 20 Years
Myths and Mythconceptions: What Does it Mean to be a Programming Language?
Why C++ is Not Just an Object-Oriented Programming Language
Who is Using AI to Code? Global Diffusion and Impact of Generative AI
How AI Impacts Skill Formation
Artificial Intelligence and Machine Learning Certificates in AI: Learn but Verify
Will Code Remain a Relevant User Interface for End-User Programming with Generative AI Models?
Toward Programming Languages for Reasoning: Humans, Symbolic Systems, and AI Agents
Vibe Coding vs. Agentic Coding: Fundamentals and Practical Implications of Agentic AI
Agentic Software Engineering: Foundational Pillars and a Research Roadmap
A Review of Trust, Risk, and Security Management in LLM-based Agentic Multi-Agent Systems
| 書名 Book Title | 作者 Author | 出版年 Publish Year | 出版者 Publisher | ISBN | 館藏來源* | 備註 Note |
|---|