Expression evaluation model
Let us define the expression evaluation more formally.
Sources
-
Let we have n sources numbered 1, 2, …, n.
-
Each source can provide values of a given type. Let D1, D2, …, Dn be domains for individual values for sources 1, 2, …, n, respectively.
-
Because each source can have multiple values of given type, the domains for sources 1, 2, …, n are power sets (sets of sets) of D1, D2, …, Dn, respectively, denoted as P(D1), P(D2), …, P(Dn).
-
And because each source has two states: old and new, the complete specification of input states can be denoted as P(D1) x P(D1), P(D2) x P(D2), …, P(Dn) x P(Dn).
Output
-
Let R be the domain for individual values of the target (output) item, i.e. evaluator range.
-
P(R) is the power set of the evaluator range: all sets of individual values of the target item.
-
P(R) x P(R) x P(R) is the set of all possible delta set triples (plus, minus, zero sets of values).
Transformation function (no deltas)
T: P(D1) x P(D2) x … x P(Dn) → P(R) |
is the transformation function that maps sets of source values to a set of output values (no deltas yet).
Transformation function (with deltas)
Then the "delta-aware" transformation Trel i.e.:
Trel : P(D1) x P(D1) x P(D2) x P(D2) x … x P(Dn) x P(Dn) → P(R) x P(R) x P(R) |
(in human words, a transformation function that maps couples (old, new) of sets of source values to the output delta set triple)
can be defined in this way:
-
let S1 ⊆ D1, S2 ⊆ D2, …, Sn ⊆ Dn be sets of old values of sources 1, 2, …, n, respectively;
-
let S1' ⊆ D1, S2' ⊆ D2, …, Sn' ⊆ Dn be sets of new values of sources 1, 2, …, n, respectively;
-
let O ⊆ R is the set of output values for the "old" state, i.e. O = T(S1, S2, …, Sn);
-
let O' ⊆ R is the set of output values for the "new" state, i.e. O' = T(S1', S2', …, Sn');
-
let (Oplus ⊆ R, Ominus ⊆ R, Ozero ⊆ R) be resulting delta set triple.
Then
Trel (S1, S1', S2, S2', …, Sn, Sn') = (Oplus, Ominus, Ozero) |
if and only if:
-
Oplus = O' - O
-
Ominus = O - O'
-
Ozero = O ∩ O'
Note that this description ignores the existence of variables. It is rather complicated even without them. If you’re interested how variables are treated, please see the description of the implementation.