Introduction

本課程將講授程式語言領域之入門理論與知識,希望培養學生以型式邏輯進行清晰思考的能力,了解邏輯與程式語言、型別系統的密切關係,以及型別系統在程式語言中扮演的角色,使學生能以遞迴/迭構方式理解並解決程式設計問題,能運用軟體工具輔助邏輯推理及證明程式正確性,並具備進一步探索程式語言相關領域的知識基礎。

Announcements

Special Topic: Monad and Side Effects

函數程式雖然常被說成是沒有副作用的,但是其實藉由函數以及型別的抽象化,尤其是藉由著名的 Monad 概念,可以更精準、更廣泛地表達並駕馭各種副作用。我們先介紹 Monad 的原理,再說明幾種歷久彌新的應用,包括搜尋、句法分析、機率運算等。我們也會跟人工智慧扯上關係,因為不論是要用「自動微分」把機器學習普及化,還是要把清晰易懂的模型變成跑得動的程式,都免不了對副作用進行推理。

Important dates

  1. 03/10
    網站上線
  2. 07/17
    外地實習生報名截止
  3. 07/20
    外校學生修課報名截止
  4. 07/25
    臺大學生報名截止
  5. 07/27
    旁聽報名截止
  6. 08/01
    課程開始
  7. 08/08
    期中停修截止
  8. 08/12
    課程結束

Courses

Functional Programming

Lecturer(s)

Shin‑Cheng Mu
Institute of Information Science, Academia Sinica

Resources

Handouts
Handouts
Source Files
Practicals
Solutions to Practicals
Supplements

Logic

Mathematical proofs are built upon valid inference structures; in formal logic, we express these structures with precise and succinct symbols, and study their properties. This course module focuses on the natural deduction system of propositional intuitionistic logic, introduces the basic syntactic and semantic proof methods used in formal logic, and points out the intimate relationship between logic and computation, leading into the topic of dependently typed programming. By studying the inference structures formally, this course module also introduces the necessary proof techniques used in other modules.

Lecturer(s)

Josh Ko
Institute of Information Science, Academia Sinica

Resources

Slides

λ-Calculus

Nowadays many languages such as Haskell and Agda are based on variants of λ-calculus. In this course module, we will investigate λ-calculus and its notions and properties mathematically. For example, we will define computation and computational equivalence; after introducing types, we show how ‘a well-typed program does not go wrong’. Apart from theoretical interests, we also discuss a prevalent language feature —polymorphism— which has been applied to solve the code duplication problem in practice. Continuing into the dependently typed programming module, we will use Agda to implement λ-calculus and prove its properties.

Lecturer(s)

Liang‑Ting Chen
Institute of Information Science, Academia Sinica

Resources

Slides

Dependently Typed Programming

Lecturer(s)

Shin‑Cheng Mu
Institute of Information Science, Academia Sinica
Josh Ko
Institute of Information Science, Academia Sinica
Liang‑Ting Chen
Institute of Information Science, Academia Sinica

Resources

Agda 安裝指南
Unicode 符號對照表
Source Files

Special Topic: Monad and Side Effects

函數程式雖然常被說成是沒有副作用的,但是其實藉由函數以及型別的抽象化,尤其是藉由著名的 Monad 概念,可以更精準、更廣泛地表達並駕馭各種副作用。我們先介紹 Monad 的原理,再說明幾種歷久彌新的應用,包括搜尋、句法分析、機率運算等。我們也會跟人工智慧扯上關係,因為不論是要用「自動微分」把機器學習普及化,還是要把清晰易懂的模型變成跑得動的程式,都免不了對副作用進行推理。

Lecturer(s)

Chung‑Chieh Shan
Department of Computer Science, Indiana University

Resources

Slides
Practicals

課表

1st week Mon Tue Wed Thu Fri
Morning Functional Programming 0Inductive definitions Functional Programming 1Folds λ-Calculus 0Untyped λ-Calculus λ-Calculus 1Simply typed λ-Calculus λ-Calculus 2Polymorphic λ-Calculus
Afternoon Logic 0Propositional logic & natural deduction Logic 1Classical semantics of propositional logic Functional Programming 2Red-black trees Logic 2Curry–Howard correspondence 討論Discussion
2nd week Mon Tue Wed Thu Fri
Morning Special Topic: Monad and Side Effects 0Dualism: Pure programming with effects, monad, type classes Special Topic: Monad and Side Effects 1Choices: Nondeterministic search & lazy sharing, parsing, probabability Special Topic: Monad and Side Effects 2AI: Gradient descent, automatic differentiation, equational reasoning Special Topic: Monad and Side Effects 3Optional topics 考試Exam
Afternoon Dependently Typed Programming 0Indexed datatypes & dependent pattern matching Dependently Typed Programming 1Shallow embedding of higher-order logic & deep embedding of propositional logic Dependently Typed Programming 2Formalisation of simply typed λ-Calculus 討論Discussion