37
Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques Garrigue, and Sungwoo Park ROSAEC Center Workshop @ 통영, 2011-01-08 (토요일)

@ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

Hyeonseung Im @ POSTECH PL 연구실Joint work with Keiko Nakata, Jacques Garrigue, and Sungwoo Park

ROSAEC Center Workshop @ 통영, 2011-01-08 (토요일)

Page 2: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

2011-01-10 ROSAEC Center Workshop @ 통영 2

큰 프로그램

Page 3: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

장점?

컴포넌트 각각의 불변성 (invariants) 및 특성을독립적으로 이해

컴포넌트 단위 개발 및 유지 보수 용이

코드 재사용

2011-01-10 ROSAEC Center Workshop @ 통영 3

Page 4: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

2011-01-10 ROSAEC Center Workshop @ 통영 4

Page 5: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

프로그래머가 알아서 잘 하면 됩니다.

2011-01-10 ROSAEC Center Workshop @ 통영 5

Page 6: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

2011-01-10 ROSAEC Center Workshop @ 통영 6

Page 7: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

프로그래밍 언어 차원에서 지원해주면 용이함

객체 지향 패러다임 모듈 시스템

2011-01-10 ROSAEC Center Workshop @ 통영 7

Page 8: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

스트럭처 (Structures or modules)

시그너처 (Signatures)

추상타입 (Abstract types)

중첩모듈 (Nested modules)

모듈함수 (functors)

2011-01-10 ROSAEC Center Workshop @ 통영 8

Page 9: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

동시에 상호 참조하는 서로 다른 모듈

따로 컴파일 (Separate compilation)

2011-01-10 ROSAEC Center Workshop @ 통영 9

Accounts Users

refers to

refers to

Page 10: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

배경지식 소개 V

연구 동기 및 목표

2011-01-10 ROSAEC Center Workshop @ 통영 10

Page 11: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

모듈 ??년 동안 연구 재귀 모듈은 ??년 동안 연구

2011-01-10 ROSAEC Center Workshop @ 통영 11

Page 12: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

모듈 30년 동안 연구 재귀 모듈은 10년 동안 연구

그러나,

2011-01-10 ROSAEC Center Workshop @ 통영 12

Page 13: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

모듈 30년 동안 연구 재귀 모듈은 10년 동안 연구

그러나,

문법 기반 타입 시스템

복시 문제

순환 타입

2011-01-10 ROSAEC Center Workshop @ 통영 13

Page 14: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

재귀 모듈을 위한 일반적인 뼈대 설계

문법 기반 타입 시스템

복시 문제 해결

순환 타입 지원

타입 안전성 보장

2011-01-10 ROSAEC Center Workshop @ 통영 14

Page 15: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

재귀 모듈을 위한 일반적인 뼈대 설계

문법 기반 타입 시스템

복시 문제 해결

순환 타입 지원

타입 안전성 보장

모듈함수 없이

2011-01-10 ROSAEC Center Workshop @ 통영 15

orthogonally

Page 16: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

배경지식 소개

연구 동기 및 목표 V

복시 문제 및 해결책

순환 타입

결론

2011-01-10 ROSAEC Center Workshop @ 통영 16

Page 17: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

module rec Tree : sig type t val max : t -> intval mk_tree : Forest.t -> t

end = structtype t = Leaf of int

| Node of int * Forest.tlet max x = match x with| Leaf i -> i| Node (i, f) ->

let j = Forest.max f in if i > j then i else j

let mk_tree x =let i = Forest.max x in Node(i, x)

end

and Forest : sigtype t val max : t -> intval combine : Tree.t -> Tree.t -> Tree.t

end = structtype t = Tree.t listlet rec max x = match x with| [] -> 0| hd :: tl -> let i = Tree.max hd inlet j = max tl in

if i > j then i else jlet combine x y = Tree.mk_tree [x; y]

end

2011-01-10 ROSAEC Center Workshop @ 통영 17

Page 18: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

module rec Tree : sig type t val max : t -> intval mk_tree : Forest.t -> t

end = structtype t = Leaf of int

| Node of int * Forest.tlet max x = match x with| Leaf i -> i| Node (i, f) ->

let j = Forest.max f in if i > j then i else j

let mk_tree x =let i = Forest.max x in Node(i, x)

end

and Forest : sigtype t val max : t -> intval combine : Tree.t -> Tree.t -> Tree.t

end = structtype t = Tree.t listlet rec max x = match x with| [] -> 0| hd :: tl -> let i = Tree.max hd inlet j = max tl in

if i > j then i else jlet combine x y = Tree.mk_tree [x; y]

end

2011-01-10 ROSAEC Center Workshop @ 통영 18

‘a listExpect a value of type Forest.t

which is an abstract type!

Abstract type

Page 19: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

module rec Tree : sig type t val max : t -> intval mk_tree : Forest.t -> t

end = structtype t = Leaf of int

| Node of int * Forest.tlet max x = match x with| Leaf i -> i| Node (i, f) ->

let j = Forest.max f in if i > j then i else j

let mk_tree x =let i = Forest.max x in Node(i, x)

end

and Forest : sigtype t val max : t -> intval combine : Tree.t -> Tree.t -> Tree.t

end = structtype t = Tree.t listlet rec max x = match x with| [] -> 0| hd :: tl -> let i = Tree.max hd inlet j = max tl in

if i > j then i else j

end

2011-01-10 ROSAEC Center Workshop @ 통영 19

Does not

typecheck!

Page 20: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

module rec Tree : sig type t val max : t -> intval mk_tree : Forest.t -> t

end = structtype t = Leaf of int

| Node of int * Forest.tlet max x = match x with| Leaf i -> i| Node (i, f) ->

let j = Forest.max f in if i > j then i else j

let mk_tree x =let i = Forest.max x in Node(i, x)

end

and Forest : sigtype t val max : t -> intval combine : Tree.t -> Tree.t -> Tree.t

end = structtype t = Tree.t listlet rec max x = match x with| [] -> 0| hd :: tl -> let i = Tree.max hd inlet j = max tl in

if i > j then i else jlet combine x y = Tree.mk_tree [x; y]

end

2011-01-10 ROSAEC Center Workshop @ 통영 20

‘a listExpect a value of type Forest.t

Abstract type

Unifiable!

Page 21: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

패스 다시 쓰기 외부에서 쓰는 이름 → 내부에서 쓰는 이름 Forest.t → t

2011-01-10 ROSAEC Center Workshop @ 통영 21

Page 22: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

module type S = rec(X)sig module Tree : STmodule Forest : SF

end

module type ST = rec(Y)sigtype tval max : Y.t -> intval mk_tree : X.Forest.t -> Y.t

end

module type SF = rec(Z)sigtype tval max : Z.t -> intval combine : X.Tree.t -> X.Tree.t -> X.Tree.t

end

rec(X : S)structmodule Tree = (rec(Y : ST with type t = Leaf of int

| Node of int * X.Forest.t)struct type t = …let max x = …let mk_tree x = …

end : ST)module Forest = (rec(Z : SF withtype t = X.Tree.t list)structtype t = …let rec max x = …let combine x y =

X.Tree.mk_tree [x; y]end : SF)

end

2011-01-10 ROSAEC Center Workshop @ 통영 22

X.Tree → Y

X.Forest → Z

X.Forest.t -> X.Tree.t

Z.t -> X.Tree.t

X.Tree.t list -> X.Tree.t

Page 23: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

배경지식 소개

연구 동기 및 목표

복시 문제 및 해결책 V

순환 타입

결론

2011-01-10 ROSAEC Center Workshop @ 통영 23

Page 24: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

module rec X : sig

type ‘a stream = ‘a * ‘a X.stream

end = struct

type ‘a stream = ‘a * ‘a X.stream

end

2011-01-10 ROSAEC Center Workshop @ 통영 24

module rec M : sig type t type s

end = structtype t = N.ttype s = A of N.s

endand N : sigtype t type s

end = structtype t = A of M.ttype s = M.s

end

Page 25: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

module rec X : sig

type ‘a stream = ‘a * ‘a X.stream

end = struct

type ‘a stream = ‘a * ‘a X.stream

end

2011-01-10 ROSAEC Center Workshop @ 통영 25

module rec M : sig type t type s

end = structtype t = N.ttype s = A of N.s

endand N : sigtype t type s

end = structtype t = A of M.ttype s = M.s

end

Weak

bisimulations!

Page 26: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

문법 기반 타입 시스템 설계 복시 문제를 해결 순환 타입을 지원 타입 안전성 증명

2011-01-10 ROSAEC Center Workshop @ 통영 26

Page 27: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

문법 기반 타입 시스템 설계 복시 문제를 해결 순환 타입을 지원 타입 안전성 증명

2011-01-10 ROSAEC Center Workshop @ 통영 27

Page 28: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

고차 모듈 함수 추가 결정 가능한 타입 체계 설계 타입 유추 알고리즘 설계

2011-01-10 ROSAEC Center Workshop @ 통영 28

Page 29: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

2011-01-10 ROSAEC Center Workshop @ 통영 29

Page 30: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

2011-01-10 ROSAEC Center Workshop @ 통영 30

Page 31: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

An external name of a type (e.g., Forest.t)

is considered as different from the internal

implementation of the same type (e.g.,

Tree.t list) inside the module that defines

the type.

2011-01-10 ROSAEC Center Workshop @ 통영 31

Page 32: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

2011-01-10 ROSAEC Center Workshop @ 통영 32

Each module has its own recursion

variable annotated with a forward

reference signature.

Only forward

references via

recursion variables

are allowed

Page 33: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

2011-01-10 ROSAEC Center Workshop @ 통영 33

Page 34: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

A type equivalence relation as the largest

weak bisimulation relation on the labeled

transition system of types

2011-01-10 ROSAEC Center Workshop @ 통영 34

Page 35: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

A type equivalence relation as the largest

weak bisimulation relation on the labeled

transition system of types

2011-01-10 ROSAEC Center Workshop @ 통영 35

To support

cyclic type

definitions

To solve the

double vision

problem

Page 36: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

2011-01-10 ROSAEC Center Workshop @ 통영 36

type t = s * s, type s = t * t |- t ≈ s

S = {(t, s), (s * s, t * t), (s, t), (t * t, s * s)} is a weak

bisimulation.

t → s * s →left,right s → t * t →left,right t

s → t * t →left,right t → s * s →left,right s

Page 37: @ POSTECH PL 연구실 Joint work with Keiko Nakata, Jacques …rosaec.snu.ac.kr/meet/file/20110109c.pdf · 2018-04-12 · Hyeonseung Im @ POSTECH PL 연구실 Joint work with Keiko

A light-weight small-step call-by-value operational

semantics using evaluation contexts

The evaluation of a program (m, e) begins by reducing

the given expression e with respect to the top-level

recursive structure m.

2011-01-10 ROSAEC Center Workshop @ 통영 37