Lecture 5 Flashcards

1
Q

What is an abstract machine (or VM)?

A

A model of computation, explaining the execution of programs.

Abstracts away the physical machine details for the programmer.

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

What are the components of an Abstract machine?

A

Single assignment store
Semantic stack

M = (S, o)
M: Machine
S: Semantic stack
o: Single assignment store

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

What does the semantic stack contain?

A

Semantic statements (pair composed of a statement and an environment)

(<s1>, E_1)</s1>

Statement: Program to be evaluated
Environment: Mappings from identifiers in code to variables in store

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

What is the notation of environments?

A

E = {<id1> -> x1, <id2> -> x2, ..., <id_n> -> x_n}</id_n></id2></id1>

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

What does the single assignment store contain?

A

Dataflow variables

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

What operations are allowed on variables in the store?

A

Creation of unbound variable

Binding to another unbound

Binding to another bound

Unification of two bound variables

Testing if variable is bound

Retrieving a variable value

Testing equivalence between two variables

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

How to variables bound to other variables behave?

A

Variables bound to another variable will always have the same value as that variable.

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

When does unification succeed?

A

When two complete values are of the same type and have the same structure and content.
Then no additional binding is performed.

When two partial values contain content that can be unified, unification succeeds. Additional binding is however performed.

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

When does evaluation of equality return true?

A

When it can be established that two variables will always have the same value.

If the two variables are bound, and have unifiable complete values (type and content).

When two variables are equivalent (bound together in store, X= Y)

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

When can equality not be established?

A

When one variable is bound to a partial value, and we are comparing a complete variable. In this case we do not know what the content of the first is.

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

What is adjunction?

A

Adding a mapping to an Environment, extending this environment.

If the <id> of an additional mapping already exist in the environment, this will be overwritten.</id>

Environments are immutable, does not change, new environment is created.

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

What is restriction?

A

Removing a mapping from an Environment.

E’ = E | {<id1>, ..., <id_n>}</id_n></id1>

E’ contain only mapping specified

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

What is lookup?

A

Retrieving variable from an environment by its ID.

E(<id1>) = x1</id1>

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

What components does Execute use?

A

Statements from stack

Mappings from the enclosed environment

Bindings from single assignment store

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

What is the execution rule of the skip statement?

A

Pop statement from stack

Leave the rest of the stack and store unchanged

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

What is the execution rule for:

(<statement1> <statement2>, E)</statement2></statement1>

A

Push (<statement1>, E) to stack
Push (<statement2>, E) to stack</statement2></statement1>

Store is unchanged

17
Q

What is the execution rule for:

(local <id> in <statement> end, E)</statement></id>

A

Update store with new unbound variable v

Update environment with mapping <id> -> v, E'</id>

push (<statement>, E') to stack</statement>

18
Q

What is the execution rule of:

(<id1> = <id2>, E)</id2></id1>

A

Bind E(<id1>) and E(<id2>) in store</id2></id1>

Leave rest of stack unchanged

19
Q

What is the execution rules of:

(<id> = <value>, E)</value></id>

A

Compute value of <value> (= c)</value>

Bind E(<id>) to value c</id>

Store O: O U {E(<id>) = c}</id>

20
Q

What is the execution rules of:

if <id> then <statement1> else <statement2> end</statement2></statement1></id>

A

Check E(<id>)
If true, push <statement1>
If false, push <statement2>
otherwise raise error</statement2></statement1></id>

21
Q

What is the execution rules of procedures?

A

({<id>0 <id>1 ... <id>n}, E)</id></id></id>

Check E(<id>0)
If bound to a procedure (p_c, E_c) where p_c has form</id>

proc {$ <id1> ... <id_n>} <statement>end</statement></id_n></id1>

Push (<statement>, Ep U E) to stack</statement>

E’ adds mapping <id_n> -> E(<id>n)</id></id_n>

22
Q

What are formal parameters?

A

Identifiers in a procedure definition

proc {$ A B}

A and B are formal

23
Q

What are actual parameters?

A

Identifier in an application

P = proc {$ A B}
{P X Y}

X and Y are actual

24
Q
A