Komponenten- und Service-orientierte Softwarekonstruktion
Vorlesung 6: BCL Type Inhabitation engineered + (CL)S
Boris D¨ udder
LS XIV – Software Engineering
TU Dortmund Sommersemester 2015
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
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
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
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
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: τ∩(σ∩ρ) = (τ∩σ)∩ρ, τ∩σ=σ∩τ, τ∩τ=τ.
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):
Example Repository (Lecture 2)
Γ = {
O
:
TrObjTr
:
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)→
Rtmp
:
D((R,R),R,R)→
R cc2pl: ((R,
R),R)→ ((R,
R),R) cl2fh:
R→
R}
Semantic Type Structure
Trackdata
Pos Temp
Coord Time Cel Fh
Cart Polar Gpst Utc
Cx Cy Radius Angle
Semantic Repository
C = {
O
:
TrObjTr
:
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)∩afst
: ((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∩acc2pl
: (R,
R)∩Cart→ (R,
R)∩Polar cl2fh:
R∩Cel→
R∩FhComposition Synthesis via Inhabitation
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
}
C `C1?:R∩Fh ;C `C1cl2fh(tmp(Tr O)):R∩Fh
C `C1?:Radius ;C `C1fst(cdn(cc2pl (pos(Tr O)))):Radius
Composition Synthesis via Inhabitation
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
}
C `C1?:R∩Fh
;C `C1cl2fh(tmp(Tr O)):R∩Fh
C `C1?:Radius ;C `C1fst(cdn(cc2pl (pos(Tr O)))):Radius
Composition Synthesis via Inhabitation
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
}
C `C1?:R∩Fh ;C `C1cl2fh(tmp(Tr O)):R∩Fh
C `C1?:Radius ;C `C1fst(cdn(cc2pl (pos(Tr O)))):Radius
Composition Synthesis via Inhabitation
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
}
C `C1?:R∩Fh ;C `C1cl2fh(tmp(Tr O)):R∩Fh C `C1?:Radius
;C `C1fst(cdn(cc2pl (pos(Tr O)))):Radius
Composition Synthesis via Inhabitation
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
}
C `C1?:R∩Fh ;C `C1cl2fh(tmp(Tr O)):R∩Fh
C `C1?:Radius ;C `C1fst(cdn(cc2pl (pos(Tr O)))):Radius
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 σ ≤ σ
0and τ ≤ τ
0then σ ∩ τ ≤ σ
0∩ τ
0and σ
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∩ ρ
0Type Inhabitation Decision Tactic
To answer Γ `? : τ apply one of the following tactics:
for τ = τ
1→ τ
2, ask Γ ∪ {τ
1} `? : τ
2for τ = a,
choosex ∈ Γ with x : σ
1→ . . . → σ
n→ a
then ask Γ `? : σ
i for all1 ≤ i ≤ n. Success if n = 0.
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
∃.
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.
Levels
Definition 2
(Levels) Given a type τ we define the level of τ , written `(τ ), as follows.
`(a) = 0, for a ∈
A∪
V;
`(τ → σ) = 1 + max{`(τ ), `(σ)};
`(
Tni=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
Tkdenote the set of all
level-k types. For a subset A of atomic types, we let
Tk(A) denote the set
Bounded Combinatory Logic bcl
k(→, ∩) [D¨ udder et al., 2012]
[`(S) ≤ k]
Γ, x : τ `
kx : S(τ ) (var) Γ `
ke : τ → τ
0Γ `
ke
0: τ Γ `
k(e e
0) : τ
0(→E)
Γ `
ke : τ
1Γ `
ke : τ
2Γ `
ke : τ
1∩ τ
2(∩I) Γ `
ke : τ τ ≤ τ
0Γ `
ke : τ
0(≤)
Deciding for bcl
k(→, ∩)
Input: Γ, τ, k Γ ={f: (0→1)∩(1→0),
x: (α→β)→(β→γ)→(α→γ)}
τ= (0→0)∩(1→1)
loop:
1 choose(x:σ)∈Γ; σ0= (0→0)→(0→0)→(0→0)∩ · · · ∩ 2 σ0:=T
{S(σ)|S∈ Sx(Γ,τ,k)}; (1→1)→(1→1)→(1→1)
3 choosem∈ {0, . . . ,kσ0k}; (0→1)→(1→0)→(0→0)∩ 4 chooseP⊆Pm(σ0); (1→0)→(0→1)→(1→1) 5 if(T
π∈Ptgtm(π)≤τ)then (0→0)∩(1→1)≤τ 6 if(m= 0)then accept;
7 else
8 forall(i= 1. . . m)
9 τ:=T
π∈Pargi(π); τ:=(0→1)∩(1→0) τ:=(1→0)∩(0→1)
10 gotoloop;
11 else reject;
(x f)f: (0→0)∩(1→1)
Deciding for bcl
k(→, ∩)
Input: Γ, τ, k Γ ={f: (0→1)∩(1→0),
x: (α→β)→(β→γ)→(α→γ)}
τ= (0→0)∩(1→1) loop:
1 choose(x:σ)∈Γ; σ0= (0→0)→(0→0)→(0→0)∩ · · · ∩ 2 σ0:=T
{S(σ)|S∈ Sx(Γ,τ,k)}; (1→1)→(1→1)→(1→1)
3 choosem∈ {0, . . . ,kσ0k}; (0→1)→(1→0)→(0→0)∩ 4 chooseP⊆Pm(σ0); (1→0)→(0→1)→(1→1) 5 if(T
π∈Ptgtm(π)≤τ)then (0→0)∩(1→1)≤τ 6 if(m= 0)then accept;
7 else
8 forall(i= 1. . . m)
9 τ:=T
π∈Pargi(π); τ:=(0→1)∩(1→0) τ:=(1→0)∩(0→1)
10 gotoloop;
11 else reject;
(x f)f: (0→0)∩(1→1)
Deciding for bcl
k(→, ∩)
Input: Γ, τ, k Γ ={f: (0→1)∩(1→0),
x: (α→β)→(β→γ)→(α→γ)}
τ= (0→0)∩(1→1) loop:
1 choose(x:σ)∈Γ; σ0= (0→0)→(0→0)→(0→0)∩ · · · ∩ 2 σ0:=T
{S(σ)|S∈ Sx(Γ,τ,k)}; (1→1)→(1→1)→(1→1)
3 choosem∈ {0, . . . ,kσ0k}; (0→1)→(1→0)→(0→0)∩
4 chooseP⊆Pm(σ0); (1→0)→(0→1)→(1→1)
5 if(T
π∈Ptgtm(π)≤τ)then (0→0)∩(1→1)≤τ 6 if(m= 0)then accept;
7 else
8 forall(i= 1. . . m)
9 τ:=T
π∈Pargi(π); τ:=(0→1)∩(1→0) τ:=(1→0)∩(0→1)
10 gotoloop;
11 else reject;
(x f)f: (0→0)∩(1→1)
Deciding for bcl
k(→, ∩)
Input: Γ, τ, k Γ ={f: (0→1)∩(1→0),
x: (α→β)→(β→γ)→(α→γ)}
τ= (0→0)∩(1→1) loop:
1 choose(x:σ)∈Γ; σ0= (0→0)→(0→0)→(0→0)∩ · · · ∩ 2 σ0:=T
{S(σ)|S∈ Sx(Γ,τ,k)}; (1→1)→(1→1)→(1→1)
3 choosem∈ {0, . . . ,kσ0k}; (0→1)→(1→0)→(0→0)∩
4 chooseP⊆Pm(σ0); (1→0)→(0→1)→(1→1) 5 if(T
π∈Ptgtm(π)≤τ)then (0→0)∩(1→1)≤τ 6 if(m= 0)then accept;
7 else
8 forall(i= 1. . . m)
9 τ:=T
π∈Pargi(π); τ:=(0→1)∩(1→0) τ:=(1→0)∩(0→1)
10 gotoloop;
11 else reject;
(x f)f: (0→0)∩(1→1)
Deciding for bcl
k(→, ∩)
Input: Γ, τ, k Γ ={f: (0→1)∩(1→0),
x: (α→β)→(β→γ)→(α→γ)}
τ= (0→0)∩(1→1) loop:
1 choose(x:σ)∈Γ; σ0= (0→0)→(0→0)→(0→0)∩ · · · ∩ 2 σ0:=T
{S(σ)|S∈ Sx(Γ,τ,k)}; (1→1)→(1→1)→(1→1)
3 choosem∈ {0, . . . ,kσ0k}; (0→1)→(1→0)→(0→0)∩
4 chooseP⊆Pm(σ0); (1→0)→(0→1)→(1→1) 5 if(T
π∈Ptgtm(π)≤τ)then (0→0)∩(1→1)≤τ 6 if(m= 0)then accept;
7 else
8 forall(i= 1. . . m)
9 τ:=T
π∈Pargi(π); τ:=(0→1)∩(1→0) τ:=(1→0)∩(0→1)
10 gotoloop;
11 else reject;
(x f)f: (0→0)∩(1→1)
Deciding for bcl
k(→, ∩)
Input: Γ, τ, k Γ ={f: (0→1)∩(1→0),
x: (α→β)→(β→γ)→(α→γ)}
τ= (0→0)∩(1→1) loop:
1 choose(x:σ)∈Γ; σ0= (0→0)→(0→0)→(0→0)∩ · · · ∩ 2 σ0:=T
{S(σ)|S∈ Sx(Γ,τ,k)}; (1→1)→(1→1)→(1→1)
3 choosem∈ {0, . . . ,kσ0k}; (0→1)→(1→0)→(0→0)∩
4 chooseP⊆Pm(σ0); (1→0)→(0→1)→(1→1) 5 if(T
π∈Ptgtm(π)≤τ)then (0→0)∩(1→1)≤τ 6 if(m= 0)then accept;
7 else
8 forall(i= 1. . . m)
9 τ:=T
π∈Pargi(π); τ:=(0→1)∩(1→0) τ:=(1→0)∩(0→1)
10 gotoloop;
11 else reject;
Complexity for Finite and Bounded CL
Theorem 3
[Rehof and Urzyczyn, 2011] For finite combinatory logic
fcl:
1
Relativized inhabitation in
fcl(→) is in
Ptime2
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
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].
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
Preventing Failing Subtypes
Redundant calculations are failed inhabitation questions. We can use subtyping to reduce unnecessary inhabitation questions:
Lemma 5
Let τ and τ
0be types with τ ≤ τ
0.
If Γ 6` ? : τ
0holds, then Γ 6` ? : τ also holds.
Exercise 2
Prove Lemma 5.
Path
Definition 6
If τ = τ
1→ · · · → τ
m→ σ, then we write σ =
tgtm(τ ) and τ
i=
argi(τ ), for i ≤ m. We say that σ is a target of τ and τ
iis 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,
1is called a path
of length m. A type τ is organized if it is a (possibly empty) intersection
of paths (those are called paths in τ ).
Path
The path lemma forms the core of the inhabitation algorithm.
Lemma 7 Let τ =
Ti∈I
τ
iwhere the τ
iare 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≤ α
jfor all j ≤ n.
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 σ
2and σ
3are not present in Γ.
Lookahead Motivation
Γ`? :τ
x=A:σ1→σ2→σ3→τ, n= 3 x=B:σ4→σ5→σ6→τ, n= 3
Γ`? :σ1 Γ`? :σ2 Γ`? :σ3 Γ`? :σ4 Γ`? :σ5 Γ`? :σ6
Lookahead Optimization
Input: Γ, τ— all types inΓandτ=T
i∈Iτiorganized loop:
1 choose(x:σ)∈Γ;
2 writeσ≡T
j∈Jσj
3 for eachi∈I, j∈J, m≤ kσkdo
4 candidates(i, j, m) :=Match(tgtm(σj)≤τi)
5 M:={m≤ kσk | ∀i∈I∃j∈J:candidates(i, j, m) =true}
6 choosem∈M;
7 for eachi∈Ido
8 chooseji∈J withcandidates(i, ji, m) =true 9 chooseSia substitution
10 chooseπi∈Pm(Si(σji))withtgtm(πi)≤τiand 11 ∀1≤l≤m∀π0∈argl(πi)∃(y:ρ)∈Γ∃a pathρ0 12 inρ∃k : Match(tgtk(ρ0)≤π0) =true
13 if(m= 0)then accept;
14 else forall(l= 1. . . m)
15 τ:=T
i∈Iargl(πi);
16 gotoloop;
□[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])]?
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 alli∈I, j∈J, m≤ kσkdo
6: candidates(i, j, m):=Match(tgtm(σj)≤τi) 7: end for
8: M:={m≤ kσk | ∀i∈I∃j∈J:candidates(i, j, m) =true}
9: if M6=∅then 10: for allm∈Mdo
11: for allji∈Jwithcandidates(i, ji, m) =true do 12: for allSiis a substitutiondo
13: for allπi∈Pm(Si(σji))withtgtm(πi)≤τiand
∀1≤l≤m∀π0∈argl(πi)∃(y:ρ)∈Γ∃a pathρ0 inρ
∃k : Match(tgtk(ρ0)≤π0) =true do
14: Add group node toτ
15: ifn= 0then
16: Markτwithtrue
17: Propagate resultτin execution graphG
Optimized Algorithm for BCL Inhabitation II
19: else
20: MarkτwithUNKNOWN
21: for alll∈ {1. . . m}do
22: Add inhabitation nodeT
i∈Iargl(πi)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
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τ0∈CSthen
19: Link parent ofτ0to existingτ0∈CS
20: else
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
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])
Operators and Corresponding Expressions in (CL)S
Mathematical (CL)S representation
example example
Atoms τ , σ
tau,sigma,τ , σ
Variables α, β
alpha,beta,α, β
→ τ → σ
tau->sigmaor τ → σ
∩ τ ∩ σ
[tau, sigma]or
[τ
,σ]
Covariant C(τ
1, . . . , τ
n)
C(tau1,...,taun)constructor
≤ τ ≤ σ
tau<=sigmaor τ ≤ σ Subst. S(α) = τ {α} => {τ }
{α} ∼> {τ }
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
0with type atoms a and a
0.
Code Example in (CL)S
Then Γ `? : a
0can 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’
}
(CL)S demonstration
Download at https://depot.tu-dortmund.de/tpqr8
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.