L8 Flashcards

1
Q

Explain Landin’s knot

A

203

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the problem associated with introducing state for the theory?

A

203-205

Every type is inhabited

Interaction between state + functions = recursive definitions

STLC is consistent but lost this when we added state

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Explain how to overcome the theoretical problem associated with state

A

206

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Describe the types, pure terms, impure terms, values, stores, contexts, store typings for the monadic language

A

207

Refs and T.
Get three new constructs for references.

Locations and wrapped impure code are both values.

Stores: loc -> value
Context: var -> type
Store Typing: loc -> type

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Give rules for pure term typing in monadic language

A

208

A location that stores a value of type X has type ref X.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Give rules for effectful term typing in monadic language

A

209

let x=e;t – the e needs to be of type T X (i.e. wrapped)

return e implies that e is of (pure) type X — it isn’t effectful (conservative approximation)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Give rules for pure op sem of monadic language

A

210

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the store typing relation? What is a configuration and configuration typing? Store and config typing for monadic language

A

213

  • well typed store = given the asserted store typing, Sigma, is every location containing a well typed value consistent with what the store typing says for that location? (need two sigmas because one acts as an accumulator that is checked before everything has been added).
  • ConfigOK=is store well typed and term well-typed (wrt impure typing relation, in empty var->type context?
  • StoreCons also ensures that all expressions in store are closed.
  • ConfigOK uses the effectful typing to check the term rather than the pure typing. A config’s term is essentially an impure rather than pure expression (for generality – as pure computations can’t depend on impure ones).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

• Pure Term Weakening:

A

214

New var can go anywhere in the context list

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

• Pure Term Exchange:

A

214

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

• Pure Term Substitution:

A

214

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

• Effectful Term Weakening:

A

215

Remember to always use the effectful term type judgement for effectful terms

Effectful weakening is about the effectful type relation not the store typing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

• Effectful Term Exchange:

A

215

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

• Effectful Term Substitution:

A

215

A pure term gets substituted into an effectful term

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Proof ordering for monadic language

A

216

Two mutually recursive judgements – need to prove each meta theory using mutual induction

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Store extension definition, store monotonicity lemma STATEMENT and proof principle

A

217

17
Q

Progress for MonL

A

218

A well typed config contains a term that is a wrapped return of a value or (imp) reduces

18
Q

Preservation for MonL

A

218

19
Q

Point of MonL

A

219

20
Q

Monads for iO language – types, pure terms, impure terms, values, contexts

A

220

Any {t} is a value

T_IO is parametrised by another type X

The impure terms have print/let/return constructs

21
Q

MonIOLan pure term typing

A

221 no store typing

22
Q

MonIOLan effectful term typing

A

222

return e also has the type of e but just under the imperative typing relation.

when a pure value is evaluated (unwrapped) by an impure let, it must have a monadic wrapper type

23
Q

MonIOLan op sem pure part

A

223

24
Q

MonIOLan op sem impure part

A

224

Remember

  • impure term can’t reduce to a pure term (use return in cases where you’d want that e.g. print returning unit)
  • let x = {t}; t1 … is an impure reduction context for t
  • return itself needs to reduce its argument using the pure relation
25
Q

limits of MonIOLan wrt encapsulating effects + comparison with checked java exceptions

A

225-229

See Types.pages

26
Q

Effects in Koka

A

230

27
Q

Define the termination property

A

204

28
Q

Give impure operational semantics of MonLan

A

211-212

  • when otherwise pure values as the result of impure reduction – use return e.g. for locations, unit
  • pure expressions only reduce by pure reduction relation
  • don’t treat stores as anything other than lists
  • let x={t};t2 reduces t with the stateful reduction until it arrives at let x={return v};t
29
Q

Actual proof of store monotonicity for MonLan

A

Not given in notes, mentioned on 217