Today: Denotational semantics

advertisement
1
Ynon Flum
Program verification – Lesson No.4:
*Note: numbers in brackets (π) are slide references
Recap on formal semantics
 We've seen in the previous lesson the operational semantics
(A.K.A - state transformer semantics) – natural ("big step") and
structural ("small step").
Today: Denotational semantics
 Key idea: Denotations – 'a mathematical meaning for a program'.
 We are trying to find a mathematical structure (a model) whose
elements will be the interpretations of our language's statements.
 Denotational semantics 'interprets' expressions and statements as
functions from states to semantic categories' domains(slide 12)
 Important features of denotational semantics:
o Syntax independence: The semantics does not involve
syntactic objects (Unlike SOS for example, which has
syntactic statements and expressions included in its
inference rules system)
o Soundness: Differently observed programs should have
different meanings (Denotations)
o Full Abstractions – Two programs which have different
denotations can be observed as different(slide 17)
2
Ynon Flum
For example: Consider the two following functions:
1.
𝜆𝑥. (𝑥 + 𝑥 + 𝑥)
2.
𝜆𝑥. (𝑥 ∗ 3)
Both are the same semantically and hence should have the
same denotation.
o Compositionality – The semantics for compound statements
depend on their sub-statements and expressions.
 We consider the while language defined before as an example.
Syntax (9):
Semantic categories: (12)
 Semantics of arithmetic operations(19-20)
 Semantics of Boolean expressions (21)
3
Ynon Flum
 Non-Termination - A Problem
 Encountered when we tried to define while statements'
denotation

We want the intuitive functionality of:
 We are trying to find a function that will describe the While loop
correctly, but does it exist?
 First attempt of a solution, define:
 But-
 Bottom line: We've got an equation defining a property of the
function that we are looking for, we need some mathematical
tools to help us solve this functional recursive equation.
4
Ynon Flum
Solving recursive equations – Introduction to domain
theory:

Dictionary: (definitions and examples in 33-48)
1. Partial Orders:
* A set with a partial order will be called a poset.
*Note: from now and on our relation will be represented by:
2. Chains:
3. Monotonicity:
4. Upper bound:
5
Ynon Flum
5. Least Upper bound: (Symbolized by:
)
Some Properties:
6. Complete partial order (cpo):
7. Pointed complete partial order (pcpo):
8. Continuous functions:
Intuitively, a function is continuous when applying it to the least upper
bound of a chain is the same as taking the least upper bound of the
chain resulting from its point-wise application.
6
Ynon Flum
Connecting the formalism and our needs(49-61):
 Properties we are looking for(to the meaning our semantics give
to our programs) :
o 1. Monotonicity – the more information (input length) our
program has, the more accurate its answer is going to be.
o 2. Continuity – when producing an output, infinite lookahead (which we cannot obtain in the perpetual
understanding of computations) does not give us more
information than finite inputs.
 We wanted our denotation for the while statement to have the
following property:
 So we've defined the following function (F):
 Now we see that our problem can be reduced to finding a fixed
point of F, but we are looking for a specific one.
7
Ynon Flum
 First, we've limited our search to continuous fixed points.
 We've the following relation on functions (F is continuous under
this relation)
 This definition models the following properties:
 Then we've proved a theorem (Tarski's fixed point theorem)
guaranteeing us the existence of a minimal fixed point (under the
assumptions that F and W are continuous)
 Finally, we've got a satisfying and correct denotation for our while
statements:
 Example that shows that the definition acts as we want it to:
Download