• Non ci sono risultati.

Logical Semantics for the First Order ς -Calculus

N/A
N/A
Protected

Academic year: 2022

Condividi "Logical Semantics for the First Order ς -Calculus"

Copied!
54
0
0

Testo completo

(1)

Logical Semantics for the First Order ς -Calculus

Ugo de’ Liguoro, Torino

Steffen van Bakel, Imperial College, London

ICTCS, Bertinoro, Oct 13-15, 2003

(2)

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:

(3)

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?

(4)

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?

(5)

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?

(6)

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.

(7)

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 of

x

by

b

in

a

, avoiding variable clashes.

(8)

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.

(9)

Type judgements

The type judgements are defined by the following natural deduction system (where

A = [`

k

: B

k k∈I

]

):

(10)

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

(11)

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

(12)

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

(13)

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

(14)

Predicates (intersection types)

The set L of predicates is inductively defined by:

σ, τ ::= κ | ω | (στ) | (σ→τ ) | h`i : σii∈Ii

(15)

Predicates (intersection types)

The set L of predicates is inductively defined by:

σ, τ ::= κ | ω | (στ) | (σ→τ ) | h`i : σii∈Ii The intended meanings are:

κ

atomic predicates,

ω

is “true”;

(16)

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;

(17)

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

τ

;

(18)

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∈I

i

holds of records whose item at

`

i

satisfies

σ

i (for all

i ∈ I

).

(19)

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

τ

”.

(20)

Predicate Assignment

A basis

Γ

is a finite set of statements

x

B

: σ

with distinct subjects. Let

A ≡ [`

i

: B

ii∈I

]

and

B, B

i any type, then:

(21)

Predicate Assignment

A basis

Γ

is a finite set of statements

x

B

: σ

with distinct subjects. Let

A ≡ [`

i

: B

ii∈I

]

and

B, B

i any type, then:

(Var) (xB : σ ∈ Γ) Γ ` xB : σ

(22)

Predicate Assignment

A basis

Γ

is a finite set of statements

x

B

: σ

with distinct subjects. Let

A ≡ [`

i

: B

ii∈I

]

and

B, B

i any type, then:

(Var) (xB : σ ∈ Γ) Γ ` xB : σ

(TypeObject) Γ, xAi : σi ` bBi i : τi

(∀i ∈ I & J ⊆ I) Γ ` [`i = ς(xAi )bii∈I]A : h`jj→τjj∈Ji

(23)

Predicate Assignment

A basis

Γ

is a finite set of statements

x

B

: σ

with distinct subjects. Let

A ≡ [`

i

: B

ii∈I

]

and

B, B

i any type, then:

(Var) (xB : σ ∈ Γ) Γ ` xB : σ

(TypeObject) Γ, xAi : σi ` bBi i : τi

(∀i ∈ I & J ⊆ I) Γ ` [`i = ς(xAi )bii∈I]A : h`jj→τjj∈Ji

(ValSelect) Γ ` aA : h`jj→τjj∈Ji Γ ` aA : σk

(k ∈ J) Γ ` a.`Bk k : τk

(24)

Predicate Assignment

A basis

Γ

is a finite set of statements

x

B

: σ

with distinct subjects. Let

A ≡ [`

i

: B

ii∈I

]

and

B, B

i any type, then:

(Var) (xB : σ ∈ Γ) Γ ` xB : σ

(TypeObject) Γ, xAi : σi ` bBi i : τi

(∀i ∈ I & J ⊆ I) Γ ` [`i = ς(xAi )bii∈I]A : h`jj→τjj∈Ji

(ValSelect) Γ ` aA : h`jj→τjj∈Ji Γ ` aA : σk

(k ∈ J) Γ ` a.`Bk k : τk

Γ ` aA : h`jjj∈Ji Γ, yA : σ ` bBk : τ

(25)

Example

Let

A ≡ [`

0

:

I

, `

1

:

I and

a ≡ [`

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.

(26)

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

(27)

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 assume

6` 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.

(28)

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

(29)

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

(30)

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 / Γ

, if

x

A

: σ ∈ Γ

implies

x

A

∈ E

.

(31)

Invariance under conversion

If Γ ` aA : ρ, and

a → a

0, then Γ ` a0A : ρ.

If Γ ` aA : ρ and

a

0

→ a

where E ` a0A for

E / Γ

, then

Γ ` a0A : ρ.

(32)

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):

(33)

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

(34)

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

(35)

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

(36)

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

(37)

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

(38)

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.

(39)

Untyped ς -models (1)

D = hD, L,

emp

,

lcond

,

sel

i

is an untyped

ς

-model if:

(40)

Untyped ς -models (1)

D = hD, L,

emp

,

lcond

,

sel

i

is an untyped

ς

-model if:

D is a λ-model and

L = {`

i

| i ∈ N }

is a

denumerable set of labels;

(41)

Untyped ς -models (1)

D = hD, L,

emp

,

lcond

,

sel

i

is an untyped

ς

-model if:

D is a λ-model and

L = {`

i

| i ∈ N }

is a

denumerable set of labels;

emp ∈ D, sel

: D × L → D

, lcond

: D × L × D → D

;

(42)

Untyped ς -models (1)

D = hD, L,

emp

,

lcond

,

sel

i

is an untyped

ς

-model if:

D is a λ-model and

L = {`

i

| i ∈ N }

is a

denumerable 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

(

lcond

x `

i

y )`

i

= y

,

i 6= j ⇒

sel

(

lcond

x `

i

y )`

j

=

sel

x `

j, i 6= j ⇒ lcond(lcond x `i y) `j z =

lcond(lcond x `i z) `j y.

(43)

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

(44)

Predicate Interpretation

If

D

is a solution of

D = At + [L → D]

+ [D → D]

,

then

[[ σ ]]

Dη

⊆ D

:

[[ ω ]]

η

= D

,

[[ κ ]]

η

= η ( κ )

, where

η : [[ κ ]] → ℘(D)

,

[[ σ

τ ]]

η

= [[ σ ]]

η

∩ [[ τ ]]

η,

[[ σ → τ ]]

η

= {d ∈ D | ∀e ∈ [[ σ ]]

η

. de ∈ [[ τ ]]

η

}

,

[[h`

i

: σ

i i∈I

i]]

ξ

= {d ∈ D | ∀i ∈ I. d · `

i

∈ [[ σ

i

]]

η

}

.

If

σ ≤ τ

then, for any

η

,

[[ σ ]]

η

⊆ [[ τ ]]

η.

(45)

Type Interpretation

Let

D

be any domain: a retraction over

D

is a continuous function

ρ : D → D

such that

ρ

2

= ρ ◦ ρ = ρ

.

Types can be interpreted by retractions setting (Scott):

[[A]]D = {d ∈ D | ρA(d) = d}.

(46)

Type Interpretation

Let

D

be any domain: a retraction over

D

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 all

i ∈ 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)))

.

(47)

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].

(48)

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]]ξ

(49)

Soundness

Set

ξ |= E

if

ξ (x

A

) ∈ [[ A ]]

D whenever

x

A

∈ E

;

E |= a

A if for all

ξ

s.t.

ξ |= E

,

[[ a

A

]]

Dξ

∈ [[ A ]]

D;

ξ |= Γ

if

x

A

: σ ∈ Γ

implies

ξ (x

A

) ∈ [[ σ ]]

η

⊆ [[ A ]]

D;

Γ |= a

A

: σ

if for all

ξ

s.t.

ξ |= Γ

,

[[ a

A

]]

Dξ

∈ [[ σ ]]

η

⊆ [[ A ]]

D.

(50)

Soundness

Set

ξ |= E

if

ξ (x

A

) ∈ [[ A ]]

D whenever

x

A

∈ E

;

E |= a

A if for all

ξ

s.t.

ξ |= E

,

[[ a

A

]]

Dξ

∈ [[ A ]]

D;

ξ |= Γ

if

x

A

: σ ∈ Γ

implies

ξ (x

A

) ∈ [[ σ ]]

η

⊆ [[ A ]]

D;

Γ |= a

A

: σ

if for all

ξ

s.t.

ξ |= Γ

,

[[ a

A

]]

Dξ

∈ [[ σ ]]

η

⊆ [[ A ]]

D.

Then

1. If

E ` a

A then

E |= a

A;

2. if

Γ ` a

A

: σ

then

Γ |= a

A

: σ

.

(51)

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∈J

i | (j 6= i & h`

j

: σ i ∈ F ) ∨ (j = i & σ

i

∈ G)

F is an untyped ς-model.

(52)

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 all

F ∈ F

and type

A ≡ [`

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.

(53)

Completeness

For all aA such that E ` aA, for some E, and all environment

ξ

s.t.

ξ |= E

:

[[aA]]Fξ = {σ | ∃Γ. ξ |= Γ & Γ ` aA : σ}

Γ ` aA : σ ⇐⇒ Γ |= aA : σ.

(54)

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).

Riferimenti

Documenti correlati

Nowadays, estrogen defi ciency (severe or mild) should be considered one of the key steps in the promotion of bone loss in men (Riggs et al 1998) as well as a major determinant in

The aim of this study was to evaluate whether modulation of endogenous heme may affect cyclooxygenase-2 expression and activity, taking advantage of two different approaches able

l’informativa fornita dai bilanci di esercizio di qualsiasi compagnia assicurativa tenuta alla redazione secondo i principi contabili internazionali. Come risultato si ha che

In the litera- ture there are a number of works where knowledge incorporation has been used, for instance in the design of evolutionary operators [ 7 ], in the selection of

(left) The bathymetry of Lake Garda, with darker shades of blue representing deeper waters, and (right)

Besides the ob- served WISP cumulative counts (from their Table 2, interpolat- ing at the Hα flux limits corrected for [N ii ] contamination), we show also dN/dz derived using

The SPF of debris discs brings an insight in the properties of the scattering particles, as recently demonstrated using Saturn’s G and D rings ( Hedman & Stark 2015 ). It

The secular variation of the disk ex- tinction supports more a precession scenario rather than a simple misalignment between the disk and the orbital plane of the inner binary,