Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
sav07_lecture_2 [2007/03/22 20:32] vkuncak |
sav07_lecture_2 [2007/03/22 20:35] vkuncak |
||
---|---|---|---|
Line 512: | Line 512: | ||
- | |||
- | ===== Semantics of references and arrays ===== | ||
- | |||
- | Program with class declaration | ||
- | |||
- | <code java> | ||
- | class Node { | ||
- | Node left, right; | ||
- | } | ||
- | </code> | ||
- | |||
- | How can we represent fields? | ||
- | |||
- | Possible mathematical model: fields as functions from objects to objects. | ||
- | |||
- | left : Node => Node | ||
- | right : Node => Node | ||
- | |||
- | What is the meaning of assignment? | ||
- | |||
- | x.f = y | ||
- | |||
- | <latex> | ||
- | f[x \mapsto y](z) = \left\{ \begin{array}{lr} | ||
- | y, & z=x \\ | ||
- | f(z), & z \neq x | ||
- | \end{array}\right. | ||
- | </latex> | ||
- | |||
- | Eliminating function updates in formulas. | ||
- | |||
- | Representing arrays. | ||
- | |||
- | What does this mean for our formulas? | ||
- | |||
- | <code java> | ||
- | assume (x.f = 1); | ||
- | y.f = 0; | ||
- | assert (x.f > 0) | ||
- | </code> | ||
- | |||
- | left, right - uninterpreted functions (can have any value, depending on the program, unlike arithmetic functions such as +,-,* that have fixed interpretation). | ||