What is Reaching Definitions Analysis?
For each location, RDA determines for each variable v the last locations where v may have been assigned.
In what direction does the LVA go and why?
-> So for us to determine for each location which variables may potentially be read before their next write, the LVA should traverse the CFA in backward direction
When a variable is alive?
When a variable is read, it becomes alive in the locations
before it.
When is a variable dead?
When a variable is written, it becomes dead in the locations
before it.
What is a live variable?
Define LVA.
What is the connection between CFAs and Semantics?
How would a CFA look like for a while statement?
We remove the exit location at CFA 1 and redirect all incoming edges the the global “l” entry location. The “l” entry location has two edges - the one leads to CFA 1 if b holds and the other leads to the exit location 0, if b doesn’t hold.
How would a CFA look like for an IF statement?
We remove both exit locations at CFA 1 and CFA 2, redirect their incoming edges to an 0 state which is the global exit location. e add a global entry location and if the condition holds, then we go to CFA 1, if not - to CFA 2.
How would a CFA for a sequence of stmt’s look like?
If we have CFA 1 and CFA 2, we remove the exit location of the CFA 1 and every edge that leads to the removed exit location we redirect to the entry location of CFA 2. We set the global entry location to the entry location of CFA 1 and the global exit location to th exit location of CFA 2.
Define CFA.
A Control Flow Automaton (CFA) is a 4-tuple
A = (L, E, entry, exit) where
▶ L ⊆ N is the finite set of locations
▶ E ⊆ L × Frag × L is the finite set of edges
▶ entry ∈ L is the entry location
▶ exit ∈ L is the exit location
Why do we need control flow?
Because the behaviour of a program at locations is dependent on surrounding locations
What is SOS and how do they work?
Explain a Concrete Transition Relation.
A concrete transition relation
→ ⊆ (Stmt × Σ) × ((Stmt ∪ {↓}) × Σ)
defines the evolution of concrete configurations during program execution.
t.e. kak se promenqt konfiguraciite dokato palim programata
t.e. 2 konfiguracii oznachava dvoika - edin stmt (programa) i stoinostite na variables v neq programa
What is a concrete configuration?
We call a pair ⟨stmt, σ⟩ ∈ ((Stmt ∪ {↓}) × Σ) a concrete configuration.
Explain the evaluation functions.
Given a state σ ∈ Σ, the evaluation functions
are defined recursively over the structure of the expressions.
Example:
Given σ = [x → 3, y → 5] ∈ Σ, it holds that
* val^Z_σ (4) = 4
* val^Z_σ (x) = 3
* val^Z_σ (x + 4) = 7
* val^B_σ (x + 4 > 5) = true
What is a concrete state space?
The concrete state space is the set of such valuations
Σ := {σ | σ : Var → Z}
What is a concrete state?
A concrete state is a function assigning a value to each variable σ : Var → Z
When is a ST_0 program P valid?
P is a valid ST0 program ⇐⇒ stmt_P has the form CYCLE stmt_rem where stmt_rem does not contain CYCLE stmt or IO
What is ST_0 program?
An ST0 program P is a tuple
P = (Var_in , Var_state , Var_out , stmt_P , init_P)
Var_in and Var_out are sets of the input and output variables.
Var_state are the state variables (t.e. vsichki variables deto se definirat za da se izplozvat v programata)
stmt_P is a labelled statement over the variables Var (Var is the set of all the variables above)
init_P is the initial assignment of all program variables
What is ST_0
Simplified programming language for Structured Text
What are formal methods?
Formal methods are made of mathematically tools for
the specification, design and verification of software and
hardware systems
What is the purpose of formal methods?
Tests give limited results, there are too many things and instances to be tested. That is why we need guaranteed system properties.
What does a definition of a variable means?
The assignment of a variable