• Keine Ergebnisse gefunden

Komponenten- und Service-orientierte Softwarekonstruktion

N/A
N/A
Protected

Academic year: 2021

Aktie "Komponenten- und Service-orientierte Softwarekonstruktion"

Copied!
48
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Komponenten- und Service-orientierte Softwarekonstruktion

Vorlesung 6: BCL Type Inhabitation engineered + (CL)S

Boris D¨ udder

LS XIV – Software Engineering

TU Dortmund Sommersemester 2015

(2)

Relativized Inhabitation

We consider the relativized inhabitation problem:

I Given Γandτ, does there existF such that Γ`clF :τ?

Relativized inhabitation in simple types is much harder than inhabitation in the fixed theory of λ

(SKI)

I Undecidable: Linial-Post theorems, 1948 ff.

Reason: instead of considering a fixed theory (λ

, IPC) we consider an arbitrary input theory

The CLS view: Already in simple types, relativized inhabitation

defines a Turing-complete logic programming language for component

composition

(3)

Relativized Inhabitation

We consider the relativized inhabitation problem:

I Given Γandτ, does there existF such that Γ`clF :τ?

Relativized inhabitation in simple types is much harder than inhabitation in the fixed theory of λ

(SKI)

I Undecidable: Linial-Post theorems, 1948 ff.

Reason: instead of considering a fixed theory (λ

, IPC) we consider an arbitrary input theory

The CLS view: Already in simple types, relativized inhabitation

defines a Turing-complete logic programming language for component

composition

(4)

Relativized Inhabitation

We consider the relativized inhabitation problem:

I Given Γandτ, does there existF such that Γ`clF :τ?

Relativized inhabitation in simple types is much harder than inhabitation in the fixed theory of λ

(SKI)

I Undecidable: Linial-Post theorems, 1948 ff.

Reason: instead of considering a fixed theory (λ

, IPC) we consider an arbitrary input theory

The CLS view: Already in simple types, relativized inhabitation

defines a Turing-complete logic programming language for component

composition

(5)

Relativized Inhabitation

We consider the relativized inhabitation problem:

I Given Γandτ, does there existF such that Γ`clF :τ?

Relativized inhabitation in simple types is much harder than inhabitation in the fixed theory of λ

(SKI)

I Undecidable: Linial-Post theorems, 1948 ff.

Reason: instead of considering a fixed theory (λ

, IPC) we consider an arbitrary input theory

The CLS view: Already in simple types, relativized inhabitation

defines a Turing-complete logic programming language for component

composition

(6)

Intersection types

Definition 1 (Intersection types)

LetVdenote a denumerable set oftype variables, ranged over by metavariables α, β, γ, . . ., and letbrange over a setBoftype constants. The setT ofintersection types, ranged over byτ, σ, ρ, . . ., is defined inductively by:

α∈V⇒α∈T b∈B⇒b∈T

τ ∈T, σ∈T⇒τ→σ∈T τ ∈T, σ∈T⇒τ∩σ∈T

Intersection types are considered modulo associativity, commutativity and idempotence of intersection: τ∩(σ∩ρ) = (τ∩σ)∩ρ, τ∩σ=σ∩τ, τ∩τ=τ.

(7)

Intersection type system λ

Γ, x:τ`x:τ(var)

Γ, x:τ`M :σ Γ`λx.M:τ→σ(→I)

Γ`M:τ →σ Γ`N:τ Γ`M N :σ (→E)

Γ`M:τ1 Γ`M:τ2

Γ`M:τ1∩τ2

(∩I) Γ`M:τ1∩τ2

Γ`M :τi

(∩E)

Major reference for this system (a.k.a. “BCD”, Barendregt-Coppo-Dezani):

(8)

Example Repository (Lecture 2)

Γ = {

O

:

TrObj

Tr

:

TrObj

D((R,R),R,R) pos

:

D((R,R),R,R)

→ ((R,

R),R) cdn

: ((R,

R),R)

→ (R,

R)

fst

: (R,

R)

R snd

: (R,

R)

R

tmp

:

D((R,R),R,R)

R cc2pl

: ((R,

R),R)

→ ((R,

R),R) cl2fh

:

R

R

}

(9)

Semantic Type Structure

Trackdata

Pos Temp

Coord Time Cel Fh

Cart Polar Gpst Utc

Cx Cy Radius Angle

(10)

Semantic Repository

C = {

O

:

TrObj

Tr

:

TrObj

D((R,R)∩Cart

,

R∩Gpst,R∩Cel

)

pos

:

D((R,R)∩a,R∩a0

,

R)

→ ((R,

R)∩a,R∩a0

)∩Pos

cdn

: ((R,

R)∩a,R)∩Pos

→ (R,

R)∩a

fst

: ((R,

R)∩Coord

R)∩

(Cart →

Cx

)∩(Polar →

Radius

)

snd

: ((R,

R)∩Coord

R)∩

(Cart →

Cy)∩(Polar

Angle

)

tmp

:

D((R,R),R,R∩a)

R∩a

cc2pl

: (R,

R)∩Cart

→ (R,

R)∩Polar cl2fh

:

R∩Cel

R∩Fh

(11)

Composition Synthesis via Inhabitation

C={

O : TrObj

Tr : TrObjD((R,R)∩Cart,R∩Gpst,R∩Cel) pos : D((R,R)∩a,R∩a0,R)((R,R)∩a,R∩a0)∩Pos cdn : ((R,R)∩a,R)∩Pos(R,R)∩a

fst : ((R,R)∩CoordR)∩

(CartCx)∩(PolarRadius) snd : ((R,R)∩CoordR)∩

(CartCy)∩(PolarAngle) tmp : D((R,R),R,R∩a)R∩a

cc2pl : (R,R)∩Cart(R,R)∩Polar cl2fh : R∩Cel R∩Fh

}

C `C1?:R∩Fh ;C `C1cl2fh(tmp(Tr O)):R∩Fh

C `C1?:Radius ;C `C1fst(cdn(cc2pl (pos(Tr O)))):Radius

(12)

Composition Synthesis via Inhabitation

C={

O : TrObj

Tr : TrObjD((R,R)∩Cart,R∩Gpst,R∩Cel) pos : D((R,R)∩a,R∩a0,R)((R,R)∩a,R∩a0)∩Pos cdn : ((R,R)∩a,R)∩Pos(R,R)∩a

fst : ((R,R)∩CoordR)∩

(CartCx)∩(PolarRadius) snd : ((R,R)∩CoordR)∩

(CartCy)∩(PolarAngle) tmp : D((R,R),R,R∩a)R∩a

cc2pl : (R,R)∩Cart(R,R)∩Polar cl2fh : R∩Cel R∩Fh

}

C `C1?:R∩Fh

;C `C1cl2fh(tmp(Tr O)):R∩Fh

C `C1?:Radius ;C `C1fst(cdn(cc2pl (pos(Tr O)))):Radius

(13)

Composition Synthesis via Inhabitation

C={

O : TrObj

Tr : TrObjD((R,R)∩Cart,R∩Gpst,R∩Cel) pos : D((R,R)∩a,R∩a0,R)((R,R)∩a,R∩a0)∩Pos cdn : ((R,R)∩a,R)∩Pos(R,R)∩a

fst : ((R,R)∩CoordR)∩

(CartCx)∩(PolarRadius) snd : ((R,R)∩CoordR)∩

(CartCy)∩(PolarAngle) tmp : D((R,R),R,R∩a)R∩a

cc2pl : (R,R)∩Cart(R,R)∩Polar cl2fh : R∩Cel R∩Fh

}

C `C1?:R∩Fh ;C `C1cl2fh(tmp(Tr O)):R∩Fh

C `C1?:Radius ;C `C1fst(cdn(cc2pl (pos(Tr O)))):Radius

(14)

Composition Synthesis via Inhabitation

C={

O : TrObj

Tr : TrObjD((R,R)∩Cart,R∩Gpst,R∩Cel) pos : D((R,R)∩a,R∩a0,R)((R,R)∩a,R∩a0)∩Pos cdn : ((R,R)∩a,R)∩Pos(R,R)∩a

fst : ((R,R)∩CoordR)∩

(CartCx)∩(PolarRadius) snd : ((R,R)∩CoordR)∩

(CartCy)∩(PolarAngle) tmp : D((R,R),R,R∩a)R∩a

cc2pl : (R,R)∩Cart(R,R)∩Polar cl2fh : R∩Cel R∩Fh

}

C `C1?:R∩Fh ;C `C1cl2fh(tmp(Tr O)):R∩Fh C `C1?:Radius

;C `C1fst(cdn(cc2pl (pos(Tr O)))):Radius

(15)

Composition Synthesis via Inhabitation

C={

O : TrObj

Tr : TrObjD((R,R)∩Cart,R∩Gpst,R∩Cel) pos : D((R,R)∩a,R∩a0,R)((R,R)∩a,R∩a0)∩Pos cdn : ((R,R)∩a,R)∩Pos(R,R)∩a

fst : ((R,R)∩CoordR)∩

(CartCx)∩(PolarRadius) snd : ((R,R)∩CoordR)∩

(CartCy)∩(PolarAngle) tmp : D((R,R),R,R∩a)R∩a

cc2pl : (R,R)∩Cart(R,R)∩Polar cl2fh : R∩Cel R∩Fh

}

C `C1?:R∩Fh ;C `C1cl2fh(tmp(Tr O)):R∩Fh

C `C1?:Radius ;C `C1fst(cdn(cc2pl (pos(Tr O)))):Radius

(16)

Subtyping

We extend our type system by a subtyping relation and a special type constant ω introduced by Dezani [Barendregt et al., 1983]. The subtyping relation ≤ is the least relation satisfying the following axioms:

σ ≤ ω, ω ≤ ω → ω, σ ∩ τ ≤ σ, σ ∩ τ ≤ τ, σ ≤ σ ∩ σ;

(σ → τ ) ∩ (σ → ρ) ≤ σ → τ ∩ ρ;

If σ ≤ σ

0

and τ ≤ τ

0

then σ ∩ τ ≤ σ

0

∩ τ

0

and σ

0

→ τ ≤ σ → τ

0

. We define the symmetric closure of ≤ as =, e.g. σ = τ iff σ ≤ τ and τ ≤ σ.

Exercise 1

Using the axioms of ≤, show that holds:

(τ → τ

0

) ∩ (ρ → ρ

0

) ≤ τ ∩ ρ → τ

0

∩ ρ

0

(17)

Type Inhabitation Decision Tactic

To answer Γ `? : τ apply one of the following tactics:

for τ = τ

1

→ τ

2

, ask Γ ∪ {τ

1

} `? : τ

2

for τ = a,

choose

x ∈ Γ with x : σ

1

→ . . . → σ

n

→ a

then ask Γ `? : σ

i for all

1 ≤ i ≤ n. Success if n = 0.

(18)

Alternating Turing Machine (ATM

ATM

Tuple M = (Σ, Q, q

0

, q

a

, q

r

, ∆). Set of states Q = Q

] Q

is partitioned into a

1

set Q

of existential states (

choose

) and

2

set Q

of universal states (

forall

).

Initial state q

0

∈ Q, an accepting state q

a

∈ Q

, and a rejecting

state q

r

∈ Q

.

(19)

Alternating Turing Machine (ATM

ATM

An accepting configuration is eventually accepting.

If C is existential and some successor of C is eventually accepting then so is C.

If C is universal and all successors of C are eventually accepting then so is C.

An input is said to be accepted by M if and only if the initial configuration is eventually accepting.

Note: Formally we define the set of all eventually accepting configurations

as the smallest set satisfying the appropriate closure conditions.

(20)

Levels

Definition 2

(Levels) Given a type τ we define the level of τ , written `(τ ), as follows.

`(a) = 0, for a ∈

A

V

;

`(τ → σ) = 1 + max{`(τ ), `(σ)};

`(

Tn

i=1

τ

i

) = max{`(τ

i

) | i = 1, . . . , n}.

The level of a substitution S, written `(S), is defined as

`(S) = max{`(S(α)) | α ∈

V

}.

A level-k type is a type τ with `(τ ) ≤ k, and a level-k substitution is a

substitution S with `(S) ≤ k. For k ≥ 0, we let

Tk

denote the set of all

level-k types. For a subset A of atomic types, we let

Tk

(A) denote the set

(21)

Bounded Combinatory Logic bcl

k

(→, ∩) [D¨ udder et al., 2012]

[`(S) ≤ k]

Γ, x : τ `

k

x : S(τ ) (var) Γ `

k

e : τ → τ

0

Γ `

k

e

0

: τ Γ `

k

(e e

0

) : τ

0

(→E)

Γ `

k

e : τ

1

Γ `

k

e : τ

2

Γ `

k

e : τ

1

∩ τ

2

(∩I) Γ `

k

e : τ τ ≤ τ

0

Γ `

k

e : τ

0

(≤)

(22)

Deciding for bcl

k

(→, ∩)

Input: Γ, τ, k Γ ={f: (01)(10),

x: (αβ)γ)γ)}

τ= (00)(11)

loop:

1 choose(x:σ)Γ; σ0= (00)(00)(00)∩ · · · ∩ 2 σ0:=T

{S(σ)|S∈ Sx(Γ,τ,k)}; (11)(11)(11)

3 choosem∈ {0, . . . ,0k}; (01)→(10)→(00)∩ 4 choosePPm0); (10)→(01)→(11) 5 if(T

π∈Ptgtm(π)τ)then (00)∩(11)≤τ 6 if(m= 0)then accept;

7 else

8 forall(i= 1. . . m)

9 τ:=T

π∈Pargi(π); τ:=(01)∩(10) τ:=(10)∩(01)

10 gotoloop;

11 else reject;

(x f)f: (00)(11)

(23)

Deciding for bcl

k

(→, ∩)

Input: Γ, τ, k Γ ={f: (01)(10),

x: (αβ)γ)γ)}

τ= (00)(11) loop:

1 choose(x:σ)Γ; σ0= (00)(00)(00)∩ · · · ∩ 2 σ0:=T

{S(σ)|S∈ Sx(Γ,τ,k)}; (11)(11)(11)

3 choosem∈ {0, . . . ,0k}; (01)→(10)→(00)∩ 4 choosePPm0); (10)→(01)→(11) 5 if(T

π∈Ptgtm(π)τ)then (00)∩(11)≤τ 6 if(m= 0)then accept;

7 else

8 forall(i= 1. . . m)

9 τ:=T

π∈Pargi(π); τ:=(01)∩(10) τ:=(10)∩(01)

10 gotoloop;

11 else reject;

(x f)f: (00)(11)

(24)

Deciding for bcl

k

(→, ∩)

Input: Γ, τ, k Γ ={f: (01)(10),

x: (αβ)γ)γ)}

τ= (00)(11) loop:

1 choose(x:σ)Γ; σ0= (00)(00)(00)∩ · · · ∩ 2 σ0:=T

{S(σ)|S∈ Sx(Γ,τ,k)}; (11)(11)(11)

3 choosem∈ {0, . . . ,0k}; (01)→(10)→(00)∩

4 choosePPm0); (10)→(01)→(11)

5 if(T

π∈Ptgtm(π)τ)then (00)∩(11)≤τ 6 if(m= 0)then accept;

7 else

8 forall(i= 1. . . m)

9 τ:=T

π∈Pargi(π); τ:=(01)∩(10) τ:=(10)∩(01)

10 gotoloop;

11 else reject;

(x f)f: (00)(11)

(25)

Deciding for bcl

k

(→, ∩)

Input: Γ, τ, k Γ ={f: (01)(10),

x: (αβ)γ)γ)}

τ= (00)(11) loop:

1 choose(x:σ)Γ; σ0= (00)(00)(00)∩ · · · ∩ 2 σ0:=T

{S(σ)|S∈ Sx(Γ,τ,k)}; (11)(11)(11)

3 choosem∈ {0, . . . ,0k}; (01)→(10)→(00)∩

4 choosePPm0); (10)→(01)→(11) 5 if(T

π∈Ptgtm(π)τ)then (00)∩(11)≤τ 6 if(m= 0)then accept;

7 else

8 forall(i= 1. . . m)

9 τ:=T

π∈Pargi(π); τ:=(01)∩(10) τ:=(10)∩(01)

10 gotoloop;

11 else reject;

(x f)f: (00)(11)

(26)

Deciding for bcl

k

(→, ∩)

Input: Γ, τ, k Γ ={f: (01)(10),

x: (αβ)γ)γ)}

τ= (00)(11) loop:

1 choose(x:σ)Γ; σ0= (00)(00)(00)∩ · · · ∩ 2 σ0:=T

{S(σ)|S∈ Sx(Γ,τ,k)}; (11)(11)(11)

3 choosem∈ {0, . . . ,0k}; (01)→(10)→(00)∩

4 choosePPm0); (10)→(01)→(11) 5 if(T

π∈Ptgtm(π)τ)then (00)∩(11)≤τ 6 if(m= 0)then accept;

7 else

8 forall(i= 1. . . m)

9 τ:=T

π∈Pargi(π); τ:=(01)∩(10) τ:=(10)∩(01)

10 gotoloop;

11 else reject;

(x f)f: (00)(11)

(27)

Deciding for bcl

k

(→, ∩)

Input: Γ, τ, k Γ ={f: (01)(10),

x: (αβ)γ)γ)}

τ= (00)(11) loop:

1 choose(x:σ)Γ; σ0= (00)(00)(00)∩ · · · ∩ 2 σ0:=T

{S(σ)|S∈ Sx(Γ,τ,k)}; (11)(11)(11)

3 choosem∈ {0, . . . ,0k}; (01)→(10)→(00)∩

4 choosePPm0); (10)→(01)→(11) 5 if(T

π∈Ptgtm(π)τ)then (00)∩(11)≤τ 6 if(m= 0)then accept;

7 else

8 forall(i= 1. . . m)

9 τ:=T

π∈Pargi(π); τ:=(01)∩(10) τ:=(10)∩(01)

10 gotoloop;

11 else reject;

(28)

Complexity for Finite and Bounded CL

Theorem 3

[Rehof and Urzyczyn, 2011] For finite combinatory logic

fcl

:

1

Relativized inhabitation in

fcl

(→) is in

Ptime

2

Relativized inhabitation in

fcl

(→, ∩) is

Exptime

-complete

Theorem 4

[D¨ udder et al., 2012] For bounded combinatory logic

bclk

:

1

Relativized inhabitation in

bclk

(→) is

Exptime

-complete for all k

2

Relativized inhabitation in

bclk

(→, ∩) is (k + 2)-

Exptime

-complete

(29)

Optimization Ideas (I)

Speed-up algorithm using logical properties term level optimizations

I normalization of intersection types

I optimization of subtyping relation≤

I bounding the substitution in types

I organization of type environmentΓ

Details can be found in [D¨udder, 2014].

(30)

Optimization Ideas (II)

Speed-up algorithm using efficient computation prevention of redundant calculations

I result caches

I reusing cached results

I cycle detection

I restriction of result sets of inhabitants

multi-core processing and parallelization

I rolling processing queues

I distributed computing barriers

(31)

Preventing Failing Subtypes

Redundant calculations are failed inhabitation questions. We can use subtyping to reduce unnecessary inhabitation questions:

Lemma 5

Let τ and τ

0

be types with τ ≤ τ

0

.

If Γ 6` ? : τ

0

holds, then Γ 6` ? : τ also holds.

Exercise 2

Prove Lemma 5.

(32)

Path

Definition 6

If τ = τ

1

→ · · · → τ

m

→ σ, then we write σ =

tgtm

(τ ) and τ

i

=

argi

(τ ), for i ≤ m. We say that σ is a target of τ and τ

i

is the i-th argument of τ . If

argi

(τ ) = ρ for all i we also write τ = ρ

m

→ σ. A type of the form τ

1

→ · · · → τ

m

→ a, where a 6= ω is an atom,

1

is called a path

of length m. A type τ is organized if it is a (possibly empty) intersection

of paths (those are called paths in τ ).

(33)

Path

The path lemma forms the core of the inhabitation algorithm.

Lemma 7 Let τ =

T

i∈I

τ

i

where the τ

i

are paths and let σ = β

1

→ . . . → β

n

→ p where p 6= ω is an atom.

We have τ ≤ σ if and only if there is an i ∈ I with

τ

i

= α

1

→ . . . → α

n

→ p and β

j

≤ α

j

for all j ≤ n.

(34)

Lookahead Motivation

Assume the following type environment Γ = {

A : σ

1

→ σ

2

→ σ

3

→ τ, B : σ

4

→ σ

5

→ σ

6

→ τ, C : σ

1

,

D : σ

4

, E : σ

5

, F : σ

6

}

Combinators with types σ

2

and σ

3

are not present in Γ.

(35)

Lookahead Motivation

Γ`? :τ

x=A:σ1σ2σ3τ, n= 3 x=B:σ4σ5σ6τ, n= 3

Γ`? :σ1 Γ`? :σ2 Γ`? :σ3 Γ`? :σ4 Γ`? :σ5 Γ`? :σ6

(36)

Lookahead Optimization

Input: Γ, τ— all types inΓandτ=T

i∈Iτiorganized loop:

1 choose(x:σ)Γ;

2 writeσT

j∈Jσj

3 for eachiI, jJ, m≤ kσkdo

4 candidates(i, j, m) :=Match(tgtmj)τi)

5 M:={m≤ kσk | ∀i∈Ij∈J:candidates(i, j, m) =true}

6 choosemM;

7 for eachiIdo

8 choosejiJ withcandidates(i, ji, m) =true 9 chooseSia substitution

10 chooseπiPm(Siji))withtgtmi)τiand 11 ∀1lm∀π0argli)∃(y:ρ)Γa pathρ0 12 inρ∃k : Match(tgtk0)π0) =true

13 if(m= 0)then accept;

14 else forall(l= 1. . . m)

15 τ:=T

i∈Iargli);

16 gotoloop;

(37)

□[Distance, R]?

distance

□[Cart, P([R; R])]?

cdn

[Pos, P([[P([R; R]), Cart]; R])]?

pos

D([[Cart, P([R; R])]; [Gpst, R]; R])?

TrV

TrObj?

O cdn

[Pos, P([[P([R; R]), Cart]; R]), P([[P([R; R]), Polar]; R])]?

□[Cart, P([R; R])]?

cdn

[Pos, P([[P([R; R]), Cart]; R])]?

pos

D([[Cart, P([R; R])]; [Gpst, R]; R])?

cdn

[Pos, P([[P([R; R]), Cart]; R]), P([[P([R; R]), Polar]; R])]?

(38)

Optimized Algorithm for BCL Inhabitation I

Require: Γ,τ=T

i∈Iτiare organized 1: Input: Γ, τ

2: PossibleSuccess:=false 3: for all(x:σ)Γdo 4: write σT

j∈Jσj

5: for alliI, jJ, m≤ kσkdo

6: candidates(i, j, m):=Match(tgtmj)τi) 7: end for

8: M:={m≤ kσk | ∀i∈Ij∈J:candidates(i, j, m) =true}

9: if M6=then 10: for allmMdo

11: for alljiJwithcandidates(i, ji, m) =true do 12: for allSiis a substitutiondo

13: for allπiPm(Siji))withtgtmi)τiand

∀1lm∀π0argli)∃(y:ρ)Γa pathρ0 inρ

∃k : Match(tgtk0)π0) =true do

14: Add group node toτ

15: ifn= 0then

16: Markτwithtrue

17: Propagate resultτin execution graphG

(39)

Optimized Algorithm for BCL Inhabitation II

19: else

20: MarkτwithUNKNOWN

21: for alll∈ {1. . . m}do

22: Add inhabitation nodeT

i∈Iargli)tog

23: PossibleSuccess:=true

24: end for

25: end if

26: end for

27: end for

28: end for

29: end for

30: end if 31: end for

32: if PossibleSuccessthen 33: return SUCCESS 34: else

35: Markτ asFAILED 36: return FAILED 37: end if

(40)

Concurrent Control Algorithm for BCL Inhabitation I

1: Input: Γ, τ

2: Q:= Initialize Working Queue 3: CS:= Initialize Success Cache 4: CF := Initialize Fail Cache 5: Γ:= OrganizeΓ

6: τN:= Normalizeτ

7: root:= Create inhabitation nodeτN

8: EnqueuerootinQ

9: Spawnnworking threads executing the task={

10:

11: whileQhas elementsand(nottermination signal received)do 12: Increase semaphoreS

13: q:= Dequeue fromQ(using assignment strategyS) 14: ifqis part of cyclethen

15: Markqas end point of cycle 16: end if

17: τ0:= Organizeτinq 18: ifτ0CSthen

19: Link parent ofτ0to existingτ0CS

20: else

(41)

Concurrent Control Algorithm for BCL Inhabitation II

23: end if

24: ifτ06∈CF then

25: if notInhabOptimized(Γ,τ0)then 26: Addτ0toCF

27: Markτ0 asFAILED

28: end if

29: Propagate result ofτ0in execution graphGE

30: end if

31: end if

32: Decrease semaphoreS 33: end while

34: } 35:

36: Wait for allnworking threads 37: Fix cycles recursively inroot

38: MarkUNKNOWN nodes asFAILEDand propagate result 39: if rootis marked withSUCCESSthen

40: return ACCEPT 41: else

42: return FAIL

(42)

Combinatory Logic Synthesizer (CL)S Features

Theorem prover (proofs-as-programs correspondence) Combinatory Logic Synthesis for BCL

0

(∩, ≤)

Version 1.0

I Proof-of-concept

I Enumerates inhabitants (even cyclic ones)

I Variable kinding

I Atomic subtyping extension for taxonomies

Version 2.0

I Algebraic optimizations

I Co-variant type constructors

(cf. [Bessai et al., 2014])

(43)

Operators and Corresponding Expressions in (CL)S

Mathematical (CL)S representation

example example

Atoms τ , σ

tau,sigma,

τ , σ

Variables α, β

alpha,beta,

α, β

→ τ → σ

tau->sigma

or τ → σ

∩ τ ∩ σ

[tau, sigma]

or

[

τ

,

σ]

Covariant C(τ

1

, . . . , τ

n

)

C(tau1,...,taun)

constructor

≤ τ ≤ σ

tau<=sigma

or τ ≤ σ Subst. S(α) = τ {α} => {τ }

{α} ∼> {τ }

(44)

Code Example in (CL)S

Assuming a type environment Γ = {

A : σ

1

→ σ

2

∩ σ

3

→ a, B : α,

C : σ

2

∩ σ

3

},

with the substitution {α 7→ σ

1

} and the atomic subtyping extension a ≤ a

0

with type atoms a and a

0

.

(45)

Code Example in (CL)S

Then Γ `? : a

0

can be coded as input for (CL)S as follows:

{

(* Type environment Gamma *)

A : sigma1 -> [sigma2, sigma3] -> a, B : alpha,

C : [sigma2, sigma3]

}, {

(* Substitution(s) *) {alpha} => {sigma1}

}, {

(* Atomic subtyping extension *) tau<=tau’

}

(46)

(CL)S demonstration

Download at https://depot.tu-dortmund.de/tpqr8

(47)

Barendregt, H., Coppo, M., and Dezani-Ciancaglini, M. (1983).

A Filter Lambda Model and the Completeness of Type Assignment.

Journal of Symbolic Logic, 48(4):931–940.

Bessai, J., Dudenhefner, A., D¨ udder, B., Martens, M., and Rehof, J.

(2014).

Combinatory Logic Synthesizer.

In Margaria, T. and Steffen, B., editors,

ISoLA’14, volume 8802,

pages 26–40.

D¨ udder, B. (2014).

Automatic Synthesis of Component & Connector-Software Architectures with Bounded Combinatory Logic.

PhD thesis, Technische Universit¨ at Dortmund, Fakult¨ at f¨ ur Informatik, Dortmund, 2014.

D¨ udder, B., Martens, M., Rehof, J., and Urzyczyn, P. (2012).

Bounded Combinatory Logic.

(48)

In

Proceedings of CSL’12, volume 16 ofLIPIcs, pages 243–258.

Schloss Dagstuhl.

Rehof, J. and Urzyczyn, P. (2011).

Finite Combinatory Logic with Intersection Types.

In

Proceedings of TLCA’11, volume 6690 of LNCS, pages 169–183.

Springer.

Referenzen

ÄHNLICHE DOKUMENTE

Rather than doing synthesis “from scratch”, we consider synthesis by composition from a given set of prefabricated building

B = SKI = {S, K, I}) we can study different combinatory calculi, since in each case we can consider a B-calculus generated from the combinators in B. Or, in yet other words, the base

The notion of eventually accepting configuration is defined by induction (i.e., the set of all eventually accepting configurations is the smallest set satisfying the following

metaprogramming (SCS) domain-specific languages declarative languages logic programming generative programming model driven design (MDD) verification. automatic

Use modal types 2 φ (“code of type φ”) to expose language distinction to compostion synthesis. Introduction of modal

Gemeinsame Abgaben von Gruppen bis zu 3 Personen

Gemeinsame Abgaben von Gruppen bis zu 3 Personen

Generiere eine JAR Datei mit einem fehlerfrei ausführbaren Produkt, welches ein Solitaire Spiel mit einem sechs Kartenstapel realisiert.. Seite 2