Logical Semantics for the First Order ς -Calculus
Ugo de’ Liguoro, Torino
Steffen van Bakel, Imperial College, London
ICTCS, Bertinoro, Oct 13-15, 2003
Questions we are addressing
Object calculi have been investigated by syntactical means, under the assumption that their models are
λ-models of some kind. We think that λ-models deserve further investigation in the special concern of
object-oriented concepts and calculi, answering the following:
Questions we are addressing
Object calculi have been investigated by syntactical means, under the assumption that their models are
λ-models of some kind. We think that λ-models deserve further investigation in the special concern of
object-oriented concepts and calculi, answering the following:
Which structures are suitable as models of object calculi?
Questions we are addressing
Object calculi have been investigated by syntactical means, under the assumption that their models are
λ-models of some kind. We think that λ-models deserve further investigation in the special concern of
object-oriented concepts and calculi, answering the following:
Which structures are suitable as models of object calculi?
Is there a simple description of types and values?
Questions we are addressing
Object calculi have been investigated by syntactical means, under the assumption that their models are
λ-models of some kind. We think that λ-models deserve further investigation in the special concern of
object-oriented concepts and calculi, answering the following:
Which structures are suitable as models of object calculi?
Is there a simple description of types and values?
Is there a logical description of such models, allowing for an assignment system to derive properties of
terms?
The untyped ς -calculus
The grammar of terms of the untyped ς-calculus is:
a, b ::= x | [`i = ς(xi)bii∈I] | a.` | a.` () ς(x)b
where
L = {`
i| i ∈ N }
is a denumerable set of labels.The untyped ς -calculus
The grammar of terms of the untyped ς-calculus is:
a, b ::= x | [`i = ς(xi)bii∈I] | a.` | a.` () ς(x)b
where
L = {`
i| i ∈ N }
is a denumerable set of labels. The reduction relation is defined by:[`i = ς(xi)bii∈I].`j → bj{xj ← [`i = ς(xi)bii∈I]}
[`i = ς(xi)bii∈I].`j () ς(x)b → [`i = ς(xi)bii∈I\j, `j = ς(xA)b]
where
a {x
←b }
is the replacement ofx
byb
ina
, avoiding variable clashes.The first order typed system OB 1
The set of types is defined by the following grammar:
A, B ::= K | [`i : Bi i∈I] where
I
is a finite set of indexes.Type judgements
The type judgements are defined by the following natural deduction system (where
A = [`
k: B
k k∈I]
):Type judgements
The type judgements are defined by the following natural deduction system (where
A = [`
k: B
k k∈I]
):(Var) (xA ∈ E) E ` xA
Type judgements
The type judgements are defined by the following natural deduction system (where
A = [`
k: B
k k∈I]
):(Var) (xA ∈ E) E ` xA
(ValObject) E, xAi ` bBi i
(∀i ∈ I) E ` [`i = ς(xAi )bBi i i∈I]A
Type judgements
The type judgements are defined by the following natural deduction system (where
A = [`
k: B
k k∈I]
):(Var) (xA ∈ E) E ` xA
(ValObject) E, xAi ` bBi i
(∀i ∈ I) E ` [`i = ς(xAi )bBi i i∈I]A
(ValSelect) E ` aA
(j ∈ I) E ` (aA.`j)Bj
Type judgements
The type judgements are defined by the following natural deduction system (where
A = [`
k: B
k k∈I]
):(Var) (xA ∈ E) E ` xA
(ValObject) E, xAi ` bBi i
(∀i ∈ I) E ` [`i = ς(xAi )bBi i i∈I]A
(ValSelect) E ` aA
(j ∈ I) E ` (aA.`j)Bj
(ValUpdate) E ` aA E, xA ` bBj
(j ∈ I) E ` (aA.`j () ς(yA)bBj)A
Predicates (intersection types)
The set L of predicates is inductively defined by:
σ, τ ::= κ | ω | (σ∧τ) | (σ→τ ) | h`i : σii∈Ii
Predicates (intersection types)
The set L of predicates is inductively defined by:
σ, τ ::= κ | ω | (σ∧τ) | (σ→τ ) | h`i : σii∈Ii The intended meanings are:
κ
atomic predicates,ω
is “true”;Predicates (intersection types)
The set L of predicates is inductively defined by:
σ, τ ::= κ | ω | (σ∧τ) | (σ→τ ) | h`i : σii∈Ii The intended meanings are:
κ
atomic predicates,ω
is “true”;σ
∧τ
is conjunction;Predicates (intersection types)
The set L of predicates is inductively defined by:
σ, τ ::= κ | ω | (σ∧τ) | (σ→τ ) | h`i : σii∈Ii The intended meanings are:
κ
atomic predicates,ω
is “true”;σ
∧τ
is conjunction;σ →τ
is true of functions sending elements that satisfyσ
into elements that satisfyτ
;Predicates (intersection types)
The set L of predicates is inductively defined by:
σ, τ ::= κ | ω | (σ∧τ) | (σ→τ ) | h`i : σii∈Ii The intended meanings are:
κ
atomic predicates,ω
is “true”;σ
∧τ
is conjunction;σ →τ
is true of functions sending elements that satisfyσ
into elements that satisfyτ
;h`
i: σ
ii∈Ii
holds of records whose item at`
isatisfies
σ
i (for alli ∈ I
).Predicates entailment
The pre-order
≤
on predicates is such that:σ ≤ τ ⇒ h` : σi ≤ h` : τ i
h`i : σii∈Ii ≤ h`j : τjj∈Ji, if J ⊆ I h`i : σii∈Ii ∧ h`j : τjj∈Ji ≤ h`k : ρk (k ∈ I ∪ J)i,
where
ρk = σk∧τk, if k ∈ I∩J, ρk = σk, if k ∈ I\J, ρk = τk, if k ∈ J\I plus axioms for the arrow,
ω
and conjunction.σ ≤ τ
reads as “σ
impliesτ
”.Predicate Assignment
A basis
Γ
is a finite set of statementsx
B: σ
with distinct subjects. LetA ≡ [`
i: B
ii∈I]
andB, B
i any type, then:Predicate Assignment
A basis
Γ
is a finite set of statementsx
B: σ
with distinct subjects. LetA ≡ [`
i: B
ii∈I]
andB, B
i any type, then:(Var) (xB : σ ∈ Γ) Γ ` xB : σ
Predicate Assignment
A basis
Γ
is a finite set of statementsx
B: σ
with distinct subjects. LetA ≡ [`
i: B
ii∈I]
andB, B
i any type, then:(Var) (xB : σ ∈ Γ) Γ ` xB : σ
(TypeObject) Γ, xAi : σi ` bBi i : τi
(∀i ∈ I & J ⊆ I) Γ ` [`i = ς(xAi )bii∈I]A : h`j:σj→τjj∈Ji
Predicate Assignment
A basis
Γ
is a finite set of statementsx
B: σ
with distinct subjects. LetA ≡ [`
i: B
ii∈I]
andB, B
i any type, then:(Var) (xB : σ ∈ Γ) Γ ` xB : σ
(TypeObject) Γ, xAi : σi ` bBi i : τi
(∀i ∈ I & J ⊆ I) Γ ` [`i = ς(xAi )bii∈I]A : h`j:σj→τjj∈Ji
(ValSelect) Γ ` aA : h`j:σj→τjj∈Ji Γ ` aA : σk
(k ∈ J) Γ ` a.`Bk k : τk
Predicate Assignment
A basis
Γ
is a finite set of statementsx
B: σ
with distinct subjects. LetA ≡ [`
i: B
ii∈I]
andB, B
i any type, then:(Var) (xB : σ ∈ Γ) Γ ` xB : σ
(TypeObject) Γ, xAi : σi ` bBi i : τi
(∀i ∈ I & J ⊆ I) Γ ` [`i = ς(xAi )bii∈I]A : h`j:σj→τjj∈Ji
(ValSelect) Γ ` aA : h`j:σj→τjj∈Ji Γ ` aA : σk
(k ∈ J) Γ ` a.`Bk k : τk
Γ ` aA : h`j:σjj∈Ji Γ, yA : σ ` bBk : τ
Example
Let
A ≡ [`
0:
I, `
1:
I anda ≡ [`
0= ς(x
A)1
,`
1= ς(x
A)x.`
0]
, such that` a
A. Then (where I stands for the type Integer, and O and E for its sub-type Odd, and Even.)xA : ω ` 1I : O
xA : h`0 : ω→Oi ` xA : h`0 : ω→Oi xA : h`0 : ω→Oi ` xA : ω xA : h`0 : ω→Oi ` (x.`0)I : O
` aA : h`0 : ω→O, `1 : h`0 : ω→Oi→Oi
Note that
`
0 is a field;`
1 is the method get`
0.Example (2)
By rule
(
ValUpdate)
one might derive` aA : h`0 : ω→O, `1ih`0 : ω→Oi→O yA : ω ` 2I : E
` (a.`0 () ς(yA)2)A : h`0 : ω→E, `1 : h`0 : ω→Oii→O
Example (2)
By rule
(
ValUpdate)
one might derive` aA : h`0 : ω→O, `1ih`0 : ω→Oi→O yA : ω ` 2I : E
` (a.`0 () ς(yA)2)A : h`0 : ω→E, `1 : h`0 : ω→Oii→O
Now
(a.`
0 ()ς (y
A)2).`
1→
∗2
, and we assume6` 2 :
O,but
6` (a.`
0 ()ς (y
A)2).`
1:
O because rule(
ValSelect)
does not apply since
6` (a.`0 () ς(yA)2) : h`0 : ω→Oi.
Example (3)
On the other hand, the following is legal as well, by rule (TypeObject):
xA : ω ` 1I : O
xA : h`0 : ω→Ei ` xA : h`0 : ω→Ei xA : h`0 : ω→Ei ` xA : ω xA : h`0 : ω→Ei ` (x.`0)I : E
` aA : h`0 : ω→O, `1h`0 : ω→Ei→Ei
Example (3)
On the other hand, the following is legal as well, by rule (TypeObject):
xA : ω ` 1I : O
xA : h`0 : ω→Ei ` xA : h`0 : ω→Ei xA : h`0 : ω→Ei ` xA : ω xA : h`0 : ω→Ei ` (x.`0)I : E
` aA : h`0 : ω→O, `1h`0 : ω→Ei→Ei
Therefore, by rule (ValUpdate), we have the assignment:
` aA : h`0 : ω→O, `1h`0 : ω→Ei→Ei yA : ω ` 2I : E
` (a.`0 () ς(yA)2)A : h`0 : ω→E, `1 : h`0 : ω→Ei→Ei
Predicate Assignment (2)
The assignment system is completed by the following
‘logical’ rules:
(ω) E ` aB
(E / Γ) Γ ` aB : ω
(∧I) Γ ` aB : σ Γ ` aB : τ Γ ` aB : σ∧τ
(≤) Γ ` aB : σ σ ≤ τ Γ ` aB : τ
If E is a context and
Γ
a basis, we say that E fits intoΓ
,written
E / Γ
, ifx
A: σ ∈ Γ
impliesx
A∈ E
.Invariance under conversion
If Γ ` aA : ρ, and
a → a
0, then Γ ` a0A : ρ.If Γ ` aA : ρ and
a
0→ a
where E ` a0A forE / Γ
, thenΓ ` a0A : ρ.
Types and Predicates
The set of all predicates L is stratified into a family
{L
A}
A of sets of predicates called languages, indexed over types (considering A→B as a type):Types and Predicates
The set of all predicates L is stratified into a family
{L
A}
A of sets of predicates called languages, indexed over types (considering A→B as a type):ω ∈ LA
Types and Predicates
The set of all predicates L is stratified into a family
{L
A}
A of sets of predicates called languages, indexed over types (considering A→B as a type):ω ∈ LA
σ ∈ LA τ ∈ LA σ∧τ ∈ LA
Types and Predicates
The set of all predicates L is stratified into a family
{L
A}
A of sets of predicates called languages, indexed over types (considering A→B as a type):ω ∈ LA
σ ∈ LA τ ∈ LA σ∧τ ∈ LA
σ ∈ LA τ ∈ LB σ→τ ∈ LA→B
Types and Predicates
The set of all predicates L is stratified into a family
{L
A}
A of sets of predicates called languages, indexed over types (considering A→B as a type):ω ∈ LA
σ ∈ LA τ ∈ LA σ∧τ ∈ LA
σ ∈ LA τ ∈ LB σ→τ ∈ LA→B σ ∈ LA→Bj
(A = [`i : Bii∈I], j ∈ I) h`j : σi ∈ LA
Types and Predicates
The set of all predicates L is stratified into a family
{L
A}
A of sets of predicates called languages, indexed over types (considering A→B as a type):ω ∈ LA
σ ∈ LA τ ∈ LA σ∧τ ∈ LA
σ ∈ LA τ ∈ LB σ→τ ∈ LA→B σ ∈ LA→Bj
(A = [`i : Bii∈I], j ∈ I) h`j : σi ∈ LA
σ ∈ LA
(σ ≤ τ) τ ∈ LA
Types and Predicates
The set of all predicates L is stratified into a family
{L
A}
A of sets of predicates called languages, indexed over types (considering A→B as a type):ω ∈ LA
σ ∈ LA τ ∈ LA σ∧τ ∈ LA
σ ∈ LA τ ∈ LB σ→τ ∈ LA→B σ ∈ LA→Bj
(A = [`i : Bii∈I], j ∈ I) h`j : σi ∈ LA
σ ∈ LA
(σ ≤ τ) τ ∈ LA
If τ ∈ LB whenever xB : τ ∈ Γ and Γ ` aA : σ is derivable, then
σ ∈ L
A.Untyped ς -models (1)
D = hD, L,
emp,
lcond,
seli
is an untypedς
-model if:Untyped ς -models (1)
D = hD, L,
emp,
lcond,
seli
is an untypedς
-model if:D is a λ-model and
L = {`
i| i ∈ N }
is adenumerable set of labels;
Untyped ς -models (1)
D = hD, L,
emp,
lcond,
seli
is an untypedς
-model if:D is a λ-model and
L = {`
i| i ∈ N }
is adenumerable set of labels;
emp ∈ D, sel
: D × L → D
, lcond: D × L × D → D
;Untyped ς -models (1)
D = hD, L,
emp,
lcond,
seli
is an untypedς
-model if:D is a λ-model and
L = {`
i| i ∈ N }
is adenumerable set of labels;
emp ∈ D, sel
: D × L → D
, lcond: D × L × D → D
; such that (writing lcond and sel in a Curryfied form):sel
(
lcondx `
iy )`
i= y
,i 6= j ⇒
sel(
lcondx `
iy )`
j=
selx `
j, i 6= j ⇒ lcond(lcond x `i y) `j z =lcond(lcond x `i z) `j y.
Untyped ς -models (2)
To build an untyped ς-model it suffices to solve:
D = At + [L → D]⊥ + [D → D]
Since any D is a λ-model, we shall freely use abstraction notation. Moreover, we use the abbreviations:
h·i = emp
h`i = dii ∈ {1,...,n}i = lcond(. . . (lcond emp `1 d1) . . .)`n dn d · `i = sel d `i
d · `i := e = lcond d `i e
Predicate Interpretation
If
D
is a solution ofD = At + [L → D]
⊥+ [D → D]
,then
[[ σ ]]
Dη⊆ D
:[[ ω ]]
η= D
,[[ κ ]]
η= η ( κ )
, whereη : [[ κ ]] → ℘(D)
,[[ σ
∧τ ]]
η= [[ σ ]]
η∩ [[ τ ]]
η,[[ σ → τ ]]
η= {d ∈ D | ∀e ∈ [[ σ ]]
η. de ∈ [[ τ ]]
η}
,[[h`
i: σ
i i∈Ii]]
ξ= {d ∈ D | ∀i ∈ I. d · `
i∈ [[ σ
i]]
η}
.If
σ ≤ τ
then, for anyη
,[[ σ ]]
η⊆ [[ τ ]]
η.Type Interpretation
Let
D
be any domain: a retraction overD
is a continuous functionρ : D → D
such thatρ
2= ρ ◦ ρ = ρ
.Types can be interpreted by retractions setting (Scott):
[[A]]D = {d ∈ D | ρA(d) = d}.
Type Interpretation
Let
D
be any domain: a retraction overD
is a continuous functionρ : D → D
such thatρ
2= ρ ◦ ρ = ρ
.Types can be interpreted by retractions setting (Scott):
[[A]]D = {d ∈ D | ρA(d) = d}.
Proposition. Let
A ≡ [`
i: B
i i∈I]
: ifρ
Bi is a retraction for alli ∈ I
, then there exists a retractionρ
A such thatρA(d) = h`i = ρA→Bi(d · `i) i∈Ii, where
ρ
A→B(d) = λx.ρ
B(d(ρ
A(x)))
.Term Interpretation over Retraction Models
We say that
(D , {ρ
A}
A)
is a retraction model if D is an untyped ς-model and{ ρ
A}
A is a family of retractions such thatρA(d) = h`i = ρA→Bi(d · `i) i∈Ii where A ≡ [`i : Bi i∈I].
Term Interpretation over Retraction Models
We say that
(D , {ρ
A}
A)
is a retraction model if D is an untyped ς-model and{ ρ
A}
A is a family of retractions such thatρA(d) = h`i = ρA→Bi(d · `i) i∈Ii where A ≡ [`i : Bi i∈I].
The term interpretation [[aA]]Dξ ∈ D, where ξ is an environment, is defined:
[[xA]]ξ = ξ(x)
[[[`i = ς(xAi )bBi i i∈I]]]ξ = h`i = λd.[[bBi i]]ξ[xi:=ρA(d)] i∈Ii [[(aA.`i)Bi]]ξ = ([[aA]]ξ· `i)[[aA]]ξ
Soundness
Set
ξ |= E
ifξ (x
A) ∈ [[ A ]]
D wheneverx
A∈ E
;E |= a
A if for allξ
s.t.ξ |= E
,[[ a
A]]
Dξ∈ [[ A ]]
D;ξ |= Γ
ifx
A: σ ∈ Γ
impliesξ (x
A) ∈ [[ σ ]]
η⊆ [[ A ]]
D;Γ |= a
A: σ
if for allξ
s.t.ξ |= Γ
,[[ a
A]]
Dξ∈ [[ σ ]]
η⊆ [[ A ]]
D.Soundness
Set
ξ |= E
ifξ (x
A) ∈ [[ A ]]
D wheneverx
A∈ E
;E |= a
A if for allξ
s.t.ξ |= E
,[[ a
A]]
Dξ∈ [[ A ]]
D;ξ |= Γ
ifx
A: σ ∈ Γ
impliesξ (x
A) ∈ [[ σ ]]
η⊆ [[ A ]]
D;Γ |= a
A: σ
if for allξ
s.t.ξ |= Γ
,[[ a
A]]
Dξ∈ [[ σ ]]
η⊆ [[ A ]]
D.Then
1. If
E ` a
A thenE |= a
A;2. if
Γ ` a
A: σ
thenΓ |= a
A: σ
.The Filter Model
If F is the set of filters over L (nonempty, upward closed sets of predicates closed under ∧), the it is a λ-model such that:
emp
= ↑h·i
;F · `
i= { σ | h`
i: σ i ∈ F }
;(F · `
i:=
G ) =
h`
j: σ
j j∈Ji | (j 6= i & h`
j: σ i ∈ F ) ∨ (j = i & σ
i∈ G)
F is an untyped ς-model.
Languages: retractions over F
The family
{ ρ
A}
A whereρ
A(F ) = F ∩ L
A, is a family of retractions turning F into a retraction model. Indeed, for allF ∈ F
and typeA ≡ [`
i: B
i i ∈ I]
:F ∩ LA = h`i = λX.(F · `i)(X ∩ LA) ∩ LBi i ∈ Ii, where
λX.e [X] = { σ → τ | τ ∈ e[↑ σ ]}
represents a continuous function over F.Moreover,
[[ σ ]]
η= {F ∈ F | σ ∈ F }
is a predicate interpretation such that, ifη ( κ ) ⊆ [[ K ]]
wheneverκ ∈ L
K, then[[ σ ]]
η⊆ [[ A ]]
ifσ ∈ L
A.Completeness
For all aA such that E ` aA, for some E, and all environment
ξ
s.t.ξ |= E
:[[aA]]Fξ = {σ | ∃Γ. ξ |= Γ & Γ ` aA : σ}
Γ ` aA : σ ⇐⇒ Γ |= aA : σ.
Further steps
Account for (first order) subtyping (some ideas, many problems).
Study higher order calculi, possibly including classes and class inheritance (mixins).
Consider hybrid calculi, like objects and MA (work in progress with Barbanera).