Lecture 5 Flashcards
What is an abstract machine (or VM)?
A model of computation, explaining the execution of programs.
Abstracts away the physical machine details for the programmer.
What are the components of an Abstract machine?
Single assignment store
Semantic stack
M = (S, o)
M: Machine
S: Semantic stack
o: Single assignment store
What does the semantic stack contain?
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
What is the notation of environments?
E = {<id1> -> x1, <id2> -> x2, ..., <id_n> -> x_n}</id_n></id2></id1>
What does the single assignment store contain?
Dataflow variables
What operations are allowed on variables in the store?
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 to variables bound to other variables behave?
Variables bound to another variable will always have the same value as that variable.
When does unification succeed?
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.
When does evaluation of equality return true?
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)
When can equality not be established?
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.
What is adjunction?
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.
What is restriction?
Removing a mapping from an Environment.
E’ = E | {<id1>, ..., <id_n>}</id_n></id1>
E’ contain only mapping specified
What is lookup?
Retrieving variable from an environment by its ID.
E(<id1>) = x1</id1>
What components does Execute use?
Statements from stack
Mappings from the enclosed environment
Bindings from single assignment store
What is the execution rule of the skip statement?
Pop statement from stack
Leave the rest of the stack and store unchanged