Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level...

49
Introduction The Language The type system Conclusion Pict: A Programming Language based on the Pi-Calculus Janus Dam Nielsen 1 Department of Computer Science University of Aarhus Mobile computing fall 2004 Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Transcript of Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level...

Page 1: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict: A Programming Language based on thePi-Calculus

Janus Dam Nielsen

1Department of Computer ScienceUniversity of Aarhus

Mobile computing fall 2004

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 2: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Outline

1 Introduction

2 The LanguagePict and πCore languageThe High levelAn example

3 The type systemTypesType safety

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 3: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

π vs. λ

ML,Haskel ,Scheme, ...

λ=

?

π − calculus(1)

The main goals are to implement a high level concurrent languagepurely in terms of the π - calculus primitives, and communicationas the sole mechanism of computation. Furthermore to design a

practical type system, combining sub-typing and higher orderpolymorphism.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 4: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Outline

1 Introduction

2 The LanguagePict and πCore languageThe High levelAn example

3 The type systemTypesType safety

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 5: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

A comparison

Pict is based on π.

Extended with primitive values:

booleansintegersetc.no change of expressivenes.

Following restrictions

asynchronouschoice free (e1 + e2)no matchreplicated inputNo importance for the practical programmer.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 6: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

A comparison

Pict is based on π.

Extended with primitive values:

booleansintegersetc.no change of expressivenes.

Following restrictions

asynchronouschoice free (e1 + e2)no matchreplicated inputNo importance for the practical programmer.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 7: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

A comparison

Pict is based on π.

Extended with primitive values:

booleansintegersetc.no change of expressivenes.

Following restrictions

asynchronouschoice free (e1 + e2)no matchreplicated inputNo importance for the practical programmer.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 8: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

A comparison

Pict is based on π.

Extended with primitive values:

booleansintegersetc.no change of expressivenes.

Following restrictions

asynchronouschoice free (e1 + e2)no matchreplicated inputNo importance for the practical programmer.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 9: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

A comparison

Pict is based on π.

Extended with primitive values:

booleansintegersetc.no change of expressivenes.

Following restrictions

asynchronouschoice free (e1 + e2)no matchreplicated inputNo importance for the practical programmer.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 10: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

A comparison

Pict is based on π.

Extended with primitive values:

booleansintegersetc.no change of expressivenes.

Following restrictions

asynchronouschoice free (e1 + e2)no matchreplicated inputNo importance for the practical programmer.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 11: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

A comparison

Pict is based on π.

Extended with primitive values:

booleansintegersetc.no change of expressivenes.

Following restrictions

asynchronouschoice free (e1 + e2)no matchreplicated inputNo importance for the practical programmer.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 12: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

A comparison cont’

π Pict Desc.

x̄y.0 x!y asynchronous outputx(y).e x?y = e input prefixe1 | e2 (e1 | e2) parallel composition(ν(x)e (new x e) channel creation!x(y).e x?*y = e replicated input

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 13: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Structural congruence

Structural congruence

(e1 | e2) ≡ (e2 | e1) (2)

((e1 | e2) | e3) ≡ (e1 | (e2 | e3) (3)

x /∈ FV (e2)

((new x : T e1) | e2) ≡ (new x : T (e1 | e2)(4)

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 14: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Reduction

Reduction

{p → v} defined

(x!v | x?p = e) → {p → v}(e)(5)

And likewise for replicated input.

{p → v}defined

(x!v | x? ∗ p = e) → ({p → v}(e) | x? ∗ p = e)(6)

Reduction proceeds under declaration and parallel composition

e1 → e2

(d e1 → d e2)

e1 → e3

(e1|e2) → (e1|e2)(7)

if true then e1 else e2 → e1 if false then e1 else e2 → e2

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 15: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Outline

1 Introduction

2 The LanguagePict and πCore languageThe High levelAn example

3 The type systemTypesType safety

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 16: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Values

Val = id variable[Label Val . . . Label Val] recordType Val Polymorphic package

(rec : T Val ) Rectype valueString String ConstantCharIntbool

Label = empty anonymous labelid Explicit label

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 17: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Patterns

Pat = id : Type variable: Type Wildcard

id : Type @ Pat Layered[Label Pat . . . Label Pat] record{ id < Type } Pat Package(rec : T Pat ) Rectype

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 18: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Processes

Abs = Pat = Proc Process abstractionProc = Val ! Val output atom

Val ? Abs input prefixVal ?* Abs ymorphic package(Proc | Proc) Parallel composition(Dec — Proc) Local declarationif Val then Proc else Proc Conditional

Dec = new id : Type Channel creation

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 19: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Outline

1 Introduction

2 The LanguagePict and πCore languageThe High levelAn example

3 The type systemTypesType safety

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 20: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Simple transformations

Declaration(new x1 . . . (new xn e))(d1 . . . dn e) ⇒ (d1 . . . (dn e))

parallel composition(run e1 e2) ⇒ (e1 | e2)

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 21: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Simple transformations

Declaration(new x1 . . . (new xn e))(d1 . . . dn e) ⇒ (d1 . . . (dn e))

parallel composition(run e1 e2) ⇒ (e1 | e2)

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 22: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Abstraction

Process abstraction:def f [x,y] = (x!y | x!y)(def x p = e1 e2) ⇒ (new x (x?*p = e1 | e2))

Mutually recursive definitions:(def x1a1 . . . and xnan) ⇒(new x1 . . . (new xn (x1?*a1 | . . . | xn?*an | e)))

Function abstractiondef f [a1 a2 a3 r] = r!vdef f [a1 a2 a3] = v (|X1 < T1 . . .Xn < Tn|l1p1 . . . lnpn):T = v⇒ X1 < T1 . . .Xn < Tn[l1p1 . . . lnpn r :!T ] = r!v

Anonymous functions:\a ⇒ (def x a x)

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 23: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Abstraction

Process abstraction:def f [x,y] = (x!y | x!y)(def x p = e1 e2) ⇒ (new x (x?*p = e1 | e2))

Mutually recursive definitions:(def x1a1 . . . and xnan) ⇒(new x1 . . . (new xn (x1?*a1 | . . . | xn?*an | e)))

Function abstractiondef f [a1 a2 a3 r] = r!vdef f [a1 a2 a3] = v (|X1 < T1 . . .Xn < Tn|l1p1 . . . lnpn):T = v⇒ X1 < T1 . . .Xn < Tn[l1p1 . . . lnpn r :!T ] = r!v

Anonymous functions:\a ⇒ (def x a x)

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 24: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Abstraction

Process abstraction:def f [x,y] = (x!y | x!y)(def x p = e1 e2) ⇒ (new x (x?*p = e1 | e2))

Mutually recursive definitions:(def x1a1 . . . and xnan) ⇒(new x1 . . . (new xn (x1?*a1 | . . . | xn?*an | e)))

Function abstractiondef f [a1 a2 a3 r] = r!vdef f [a1 a2 a3] = v (|X1 < T1 . . .Xn < Tn|l1p1 . . . lnpn):T = v⇒ X1 < T1 . . .Xn < Tn[l1p1 . . . lnpn r :!T ] = r!v

Anonymous functions:\a ⇒ (def x a x)

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 25: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Abstraction

Process abstraction:def f [x,y] = (x!y | x!y)(def x p = e1 e2) ⇒ (new x (x?*p = e1 | e2))

Mutually recursive definitions:(def x1a1 . . . and xnan) ⇒(new x1 . . . (new xn (x1?*a1 | . . . | xn?*an | e)))

Function abstractiondef f [a1 a2 a3 r] = r!vdef f [a1 a2 a3] = v (|X1 < T1 . . .Xn < Tn|l1p1 . . . lnpn):T = v⇒ X1 < T1 . . .Xn < Tn[l1p1 . . . lnpn r :!T ] = r!v

Anonymous functions:\a ⇒ (def x a x)

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 26: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Complex values

(new n c!n)[[x → c]] = c!x[[k → c]] = c!k

[[(dv) → c]] = (d [[v → c]])[[(rec : Tv) → c]] = (new c ′ ([[v → c ′]] | c ′?x = c!(rec:T x))))

[[{T}v → c]] = (new c ′ ([[v → c ′]] | c ′?x = c!{T} x)))[[[l1v1 . . . lnvn] = (new c1 ([[v1 → c1]] | c1x1 = . . .

(new cn ([[vn → cn]] | cnxn =c![l1x1 . . . lnxn)) . . . ))

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 27: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Named values and application

Named value declaration:(val p=v e) ⇒ (new c ([[v → c]] | c?p = e))Application:(v v1 . . . vn) [[(v |T1 . . .Tn| l1v1 . . . lnvn) → c]]

= (new c ′ ([[v → c ′]] | c ′?x = . . .(new c1 ([[v1 → c1]] | c1?x1 = . . .(new cn ([[vn → cn]] | cn?xn =x!T1 . . .Tn[l1x1 . . . lnxn c])) . . . ))))

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 28: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Outline

1 Introduction

2 The LanguagePict and πCore languageThe High levelAn example

3 The type systemTypesType safety

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 29: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Hello world.

run ( print!”hello” — print!”world” )

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 30: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Polymorphism.

def print2nd [#X l: (List X) p:/[X /String]] =if (null l) then

print!”Null list”else if (null (cdr l)) then

print!”Null tail”else

print!(p (car (cdr l)))run print2nd![#Int (cons ¿ 6 8 9 nil) int.toString]run print2nd![#String (cons ¿ ”A” ”B” ”C” nil) \(s:String) = s]

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 31: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Pict and πCore languageThe High levelAn example

Fibo

def fibo[n:Int r:!Int] =if (—— (== n 0) (== n 1)) then

r!1else

r!(+ (fibo (- n 1)) (fibo (- n 2)))run printi!(fibo 4)

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 32: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

TypesType safety

Outline

1 Introduction

2 The LanguagePict and πCore languageThe High levelAn example

3 The type systemTypesType safety

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 33: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

TypesType safety

The basics

Types of channels and of the values they carry.

Why types?

Types are useful at ensuring consistent use of channel namesand eliminating pattern matching failures.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 34: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

TypesType safety

The basics

Types of channels and of the values they carry.

Why types?

Types are useful at ensuring consistent use of channel namesand eliminating pattern matching failures.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 35: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

TypesType safety

The basics

Types of channels and of the values they carry.

Why types?

Types are useful at ensuring consistent use of channel namesand eliminating pattern matching failures.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 36: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

TypesType safety

Subtyping

Subtyping on channel types

Refinements of the channel type ˆT.!T for output only?T for reading only.

Natural subtype relation since ˆT can be used anywhere oneof the other two is used.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 37: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

TypesType safety

Subtyping

Subtyping on channel types

Refinements of the channel type ˆT.!T for output only?T for reading only.

Natural subtype relation since ˆT can be used anywhere oneof the other two is used.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 38: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

TypesType safety

Recursive types

Types for recursive data structures like lists and trees.

Some alternatives.

We go for the simple one, where “folding” and “unfolding” ofrecursion must be handled explicitly by the programmer.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 39: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

TypesType safety

Recursive types

Types for recursive data structures like lists and trees.

Some alternatives.

We go for the simple one, where “folding” and “unfolding” ofrecursion must be handled explicitly by the programmer.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 40: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

TypesType safety

Recursive types

Types for recursive data structures like lists and trees.

Some alternatives.

We go for the simple one, where “folding” and “unfolding” ofrecursion must be handled explicitly by the programmer.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 41: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

TypesType safety

Polymorphism

Polymorphic types are supported by means of package valuesand patterns.

Polymorphic functions are represented as output channelscarrying package values.

Polymorphism and subtyping is combined by providing anupper bound on each bound type variable in a package value.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 42: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

TypesType safety

Polymorphism

Polymorphic types are supported by means of package valuesand patterns.

Polymorphic functions are represented as output channelscarrying package values.

Polymorphism and subtyping is combined by providing anupper bound on each bound type variable in a package value.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 43: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

TypesType safety

Polymorphism

Polymorphic types are supported by means of package valuesand patterns.

Polymorphic functions are represented as output channelscarrying package values.

Polymorphism and subtyping is combined by providing anupper bound on each bound type variable in a package value.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 44: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

TypesType safety

Type inference

The core language is explicitly typed, but some typeinformation can be derived from the context.

The x in c?x=e has type int if c has typeˆint

The inferennce algorithm is local in that it only uses theimmediate surrounding context to determine the type.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 45: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

TypesType safety

Outline

1 Introduction

2 The LanguagePict and πCore languageThe High levelAn example

3 The type systemTypesType safety

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 46: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

TypesType safety

Type safety

Conjecture: Evaluation can not fail in well-typed processes.

Conjecture: Reduction preserves typing.

No proofs, but nice features!

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 47: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

TypesType safety

Type safety

Conjecture: Evaluation can not fail in well-typed processes.

Conjecture: Reduction preserves typing.

No proofs, but nice features!

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 48: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

TypesType safety

Type safety

Conjecture: Evaluation can not fail in well-typed processes.

Conjecture: Reduction preserves typing.

No proofs, but nice features!

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus

Page 49: Pict: A Programming Language based on the Pi-Calculus · Pict and π Core language The High level An example A comparison Pict is based on π. Extended with primitive values: booleans

IntroductionThe Language

The type systemConclusion

Conclusion

Pict a programming language based on π.

A typesystem for Pict.

Pict can be implemented efficiently.

Janus Dam Nielsen Pict: A Programming Language based on the Pi-Calculus