• Keine Ergebnisse gefunden

5.2 Delimited control 95

96 A semantic procedure for scope construal 5 of an expression that may be subject to rule application. So the context can be seen as the focus of the rule that is going to be performed next. For example, in the expression (5.42) above, the reduction of (λP.∃x.(P x) unicorn) takes place in following context:

(λp.((knowp)enki) [ ])

Why is it useful to be able to express this? There are two things we can do with evaluation contexts once we can talk about them explicitly. First, we can restrict them as to allow rule applications only in some contexts but not in others. And second, we can manipulate them. We will need both in the next section, so let us look at them in turn.

Let us start with restricting rule applications to certain evaluation contexts.

As an example, recall the rule for beta-reduction:

((λx.E1)E2)BE1{x7→E2}

It describes the computation step of reducing an expression, independent of any context. That is, wherever the expression ((λx.E1)E2) occurs in another expression, we can rewrite it asE1{x7→E2}. Now consider we do not want to allow beta-reduction in all contexts. One way to restrict it is, for example, by specifying it as follows, where V stands forvalues of the language (constants, variables, and abstractions, but no applications):

((λx.E)V)BE{x7→V}

This rule now only applies to applications where the argument is a value, i.e.

an unreducible expression. So in our example,

(λp.((knowp)enki) (λP.∃x.(P x) unicorn)),

we can no longer substitute the unreduced expression (λP.∃x.(P x) unicorn) forp. This we can do only once we reduced it to the value∃x.(unicornx). We therefore enforce an order of reductions. This particular one is called call-by-value, because functions can be applied only to values.

And there is another way to restrict evaluation contexts. Consider the following expression:

((λP.P wise) (λx.xenki))

Although we specified call-by-value evaluation, we have two possibilities to proceed here: either first reduce (λP.P wise), or first reduce (λx.x enki). Let us say we want to fix the order of reductions such that they operate from left to right. We can do so by means of context rules, which have the general form:

IfEBE0, thenC[E]BC[E0].

This expresses that ifE reduces toE0, then we can rewriteEasE0 in context C. For instance, specifying the context as application, we could have a context rule of the following form:

IfEBE0, then (V E)B(V E0).

5.2 Delimited control 97 It expresses that if an expression E reduces to E0, then we may rewrite the former as the latter in the argument of an application if the applicand is already a value (i.e. a non-reducible expression). A more compact way of representing this rule is by means of the evaluation context (V [ ]). Thus, imagine we want to allow beta-reduction for arguments only if the applicand is non-reducible, then we would specify the rule for beta-reduction like this:

(V (λx.E1 E2))B(V E1{x7→E2})

Since this is not very clear and since we would have to define a separate rule for all contexts we want to allow, we rather specify the admissible evaluation contextsC by means of a grammar like the following:

C ::= [ ] | (V C) | (C E)

It specifies that holes can occur as arguments of applications when the appli-cand is a value, and as appliappli-cands of applications regardless of the argument.

Now we formulate the rule for beta-reduction with respect to such contextsC:

C[(λx.E1E2)]BC[E1{x7→E2}]

This way we not only provide a computational rule that specifies how to rewrite expressions but we also fix the contexts in which this rule can be applied.

This determines that ([ ] (λx.x enki)) is a valid evaluation context for beta-reduction (because we can generate it with the grammar for C), therefore we can beta-reduce whatever expression occurs in the position indicated by the hole, whereas ((λP.P wise) [ ])) is not a valid evaluation context for beta-reduction, because the hole occurs in the applicand of an application (i.e. we cannot generate the context with the grammar forC). So when reducing the expression ((λP.P wise) (λx.xenki)), we first have to reduce the left applica-tion, because the right one would take place in an illicit context. We succeeded in fixing a left-to-right order of evaluation.

Now let us turn to the possibility of manipulating evaluation contexts. To see why this is useful and how it can be done, recall the example in (5.40) above:

Gilgamesh rejected every goddess. We encountered a type mismatch when trying to apply the verb denotation of type e→ (e →t) to the object noun phrase denotation of type (e→t)→t. The corresponding semantic expression is the following:

(reject λP.∀x.(goddess x)⇒(P x))

The idea of Quantifying In amounts to transforming this expression into the following one:

(λP.∀x.(goddessx)⇒(P x) λz.(rejectz))

To see how to get there, let us first look at the original term from the perspective of the object noun phrase. The evaluation context of that noun phrase is

98 A semantic procedure for scope construal 5 (reject[ ]). If we write it as a lambda expression, it corresponds toλz.(rejectz).

The next step then is to apply the denotation of the object noun phrase to this reified evaluation context. So the gist of the Quantifying In strategy is to pull the noun phrase denotation out of its context and apply it to it. Note that this manipulates the evaluation context of the noun phrase because it no longer is the initial (reject[ ]) but a new one, namely ([ ] λz.(reject z)). In a way, we endow the noun phrase with control over its evaluation context, for it is now able to take scope over it.

In order to make this manipulation of the evaluation context explicit, two things need to be specified. First, we need to formulate the computational rule that allows an expression to take control over its context. And second, we need to delimit the context it can control. This is important for imagine an expressionE (e.g. a generalized quantifier) occurs in the following expression:

((know(dieE))gilgamesh)

There are several evaluation contexts that can be considered:

• (die[ ])

• (know(die[ ]))

• ((know(die[ ]))gilgamesh)

The next section will be dedicated to explicating the mechanism that en-ables expressions to take control over a delimited context, for short: the mech-anism ofdelimited control, and to incorporate it into the meaning dimension of the grammar. The tool that theoretical computer science knows for accessing and manipulating evaluation contexts are control operators, such as control (cf. Feilleisen [39]) and shift(cf. Danvy & Filinski [30]). They are members of a family of delimited control operators and have, in fact, the same expressive power (see the interdefinability results of Shan [101] and Kiselyov [62]). They come with delimiters called promptand reset, that delimit the context that is accessed.

In this chapter, I will employshiftas a meaning component of quantifica-tional noun phrases and wh-phrases, in order to let them capture and modify (in particular take scope over) their evaluation contexts. This builds mainly on work by Barker and Shan; I will draw connections in Section 5.7 below. The reason to chose shift over control is its static scoping (as opposed to the dynamic scoping ofcontrol). We will see what this means in the next section.

Let us first have a look at how delimited control works in general. We will write shift as ξ and reset as h i. More specifically, we will employ expres-sions of the form ξk.E and hEi. The reduction rule for expressions ξk.E will specify an operation over the evaluation context: The context up to the nearest enclosing reset is captured, reified as a function and bound to k. To illustrate this, consider the following arithmetic expression:

6 +h4 +ξk.((k 2)×(k7))i

5.3 Extending the meaning dimension 99