0% found this document useful (0 votes)
14 views54 pages

Lecture 1

Uploaded by

heiyan2020
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views54 pages

Lecture 1

Uploaded by

heiyan2020
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Foundations of Programming Languages

Hongfei Fu

John Hopcroft Center for Computer Science


Shanghai Jiao Tong University

Mar. 5th, 2020

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 1 / 37


Course Materials

The Textbook
Glynn Winskel
The Formal Semantics of Programming Languages: An Introduction

The MIT Press, 1993

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 2 / 37


Lecturer

Lecturer: Hongfei Fu
Research: Model Checking, Program Verification
Website: [Link]
Email: fuhf@[Link]
Office: Room 1408-1, Software Expert Building
Office-Hour: Wednesday afternoon, every week

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 3 / 37


What is the course about?

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 4 / 37


Programming Languages

imperative languages: C, C++, Java, Python, . . .


functional languages: Haskell, ML, OCaml, . . .
assembly languages: MASM, NASM, . . .

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 5 / 37


Programming Languages

source: from internet

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 6 / 37


Programming Languages

Compilers

source: from internet

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 7 / 37


Programming Languages

OS Kernel Development

source: from internet

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 8 / 37


Programming Languages

source: from internet


Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 9 / 37
Programming Languages

Autonomous Driving

source: from internet

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 10 / 37


Programming Languages

Embedded Systems

source: from internet

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 11 / 37


Course Focus

Program Semantics

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 12 / 37


Course Focus

Program Semantics
programs as mathematical objects

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 12 / 37


Course Focus

Program Semantics
programs as mathematical objects
logical characterizations of programs

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 12 / 37


Course Focus

Program Semantics
programs as mathematical objects
logical characterizations of programs
mathematical properties for programs

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 12 / 37


Course Focus

Program Semantics
programs as mathematical objects
logical characterizations of programs
mathematical properties for programs

Warning!
This course is not about how to write programs!!!

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 12 / 37


Course Focus

Why study programs mathematically?

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 13 / 37


Course Focus

Why study programs mathematically?

fundamental components

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 13 / 37


Course Focus

Why study programs mathematically?

fundamental components
rising complexity

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 13 / 37


Course Focus

Why study programs mathematically?

fundamental components
rising complexity
main factor in system performance

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 13 / 37


Course Focus

Why study programs mathematically?

fundamental components
rising complexity
main factor in system performance
main reason for system failure

Potential Hazard of Program Error


malfunction of codes
crash of systems
attack from hackers
...

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 13 / 37


Course Focus

Program Analysis
Experiential approaches for analyzing programs:
automated detection of potential bugs
automated detection of potential vulnerabilities
automated repair of potential bugs
automated detection of potential vulnerabilities
...

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 14 / 37


Course Focus

Program Verification
Formal approaches for analyzing programs:
rigorous proof for absence of bugs
rigorous proof for absence of vulnerabilities
full enumeration of race situations
timing analysis of programs
...

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 15 / 37


Course Focus

Testing Approaches

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 16 / 37


Course Focus

Testing Approaches
easy to conduct
can detect normal bugs
less coverage over codes
more tendency to neglect critical bugs
inapplicable in certain situations (e.g., concurrency)

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 16 / 37


Stuxnet

Stuxnet Computer Worm:


targets programmable logic controllers;
hinders automation of electromechanical processes;
damaged Iran’s nuclear plants.

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 17 / 37


WannaCry

WannaCry Ransomware:
utilizes a flaw in the Microsoft SMB protocol;
enforces encryption of data and demands ransom;
affected computers worldwide.

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 18 / 37


Timsort

Timsort Implementation Bug:


is introduced by optimization on merge sort;
is widely used;
causes software crash;
happens rarely.

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 19 / 37


Retrospect

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 20 / 37


Retrospect

Subtle critical bugs are hard to detect through testing.

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 20 / 37


Retrospect

Subtle critical bugs are hard to detect through testing.


Subtle critical bugs can be devastating if they are triggered.

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 20 / 37


Retrospect

Subtle critical bugs are hard to detect through testing.


Subtle critical bugs can be devastating if they are triggered.
Subtle critical bugs are vulnerable against adversaries.

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 20 / 37


Successful Stories

functionally-correct operating system: SEL4


hacker-free operating system: CertiKOS
error-free compiler: CompCert, L2C
race-free concurrency: Astrée
...

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 21 / 37


Successful Stories

SEL4 Operating System

source: from internet

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 22 / 37


Successful Stories

CertiKOS Operating System

source: from internet


Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 23 / 37
Successful Stories

CompCert Compiler

source: from internet

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 24 / 37


Successful Stories

Astrée Static Analyzer

source: from internet


Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 25 / 37
Successful Stories

L2C: A Formally Verified Compiler From Lustre To C

source: from internet

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 26 / 37


Successful Stories

Amazon Web Services

source: from internet

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 27 / 37


Perspective

Program Analysis/Verification

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 28 / 37


Perspective

Program Analysis/Verification
is difficult, but not infeasible.

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 28 / 37


Perspective

Program Analysis/Verification
is difficult, but not infeasible.
has much better guarantee than testing.

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 28 / 37


Perspective

Program Analysis/Verification
is difficult, but not infeasible.
has much better guarantee than testing.
is necessary in critical systems.

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 28 / 37


Perspective

Program Analysis/Verification
is difficult, but not infeasible.
has much better guarantee than testing.
is necessary in critical systems.

In Our Course:
Program semantics provides a solid theoretical foundation for program
analysis/verification.

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 28 / 37


What will the course cover?

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 29 / 37


Course Content

Program Semantics
operational semantics: how do programs execute ?
denotational semantics: what do programs output ?
axiomatic semantics: which requirements do programs meet ?

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 30 / 37


Course Content

Types of Programs
(mostly) imperative programs
(some) functional programs

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 31 / 37


Course Content

Types of Programs
(mostly) imperative programs
(some) functional programs

Technical Content
logical definitions for programs
mathematical background behind program semantics

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 31 / 37


Course Content

Chapter 1: set theory


Chapter 2,3,4: operational semantics
Chapter 5: denotational semantics
Chapter 6,7: axiomatic semantics
Chapter 8: domain theory (if we have time)
Chapter 11: typed languages

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 32 / 37


What can we gain from this course?

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 33 / 37


Course Benefits

a rigorous thinking of programs


a comprehensive start to program analysis and verification

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 34 / 37


Course Evaluation

Evaluation

final exam 50%


homework 30%
attendance 20%

Remark
In case you are sick, or you need to attend conferences/meetings at
class time, please inform me in advance.
You can submit your homework any time before the 15th week, either
in paper form or electronically via email/canvas.

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 35 / 37


Wechat Group Code for the Course

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 36 / 37


Questions?

Hongfei Fu (SJTU JHC) Foundations of Programming Languages Mar. 5th, 2020 37 / 37

You might also like