# Review of Update Formal Model

```v1.65
Main points:
The definitions look right.

I have a suggestion to write them differently for clarity (the details
need careful checking but I thought "now" and "outline" was better than
"later" and "detailed").

Andy

-------------

4.1.2:
The use of time isn't necessary - see below where t isn't used.

4.1.3 UpdateOperation
Need to define UpdateRequest as a sequence of UpdateOperations.  An
UpdateRequest is atomic.

Applying an UpdateRequest is defined as applying each UpdateOperation in
sequence order.

4.2.1 InsertDataOperation

Need to say something about how the {triples} and {(<i>, triples_i)}

It's {(<i>, {triples_i)}} -- an extra {} to show it's a set of triples
a set of pairs of uri and a set of triples (= a graph).

<i> gets overused.  It would be clearer to distinguish <i> in the
starting GS and the <j>, say, coming from the operation.

UNION: Set union doesn't quite do the right there here.  It does not
merge the two structures which is what we want.

I think the best way is to define two auxillary operations GS-UNION  and
GS-DIFF that do the work (they get used several times in the definitions):

Write DS' = {triples}, {(<j>, {triples_j})}) from parsing
then

Write I for the set of <i>, J for the set of <j>

OpInsertData(GSS(GS), DS') = GS-UNION(GSS,DS')

where
GS-UNION(GSS, DS) =
GS-UNION((DG1, {(<i>, G_i)}), (DG2, {(<j>, G_j)}) =
( DG1 union DG2,
{{triples_k}) | k in I union J })

where
{triples_k} = {triples_i} union { triples_j}
if i = k, j = k and k in I and k in J

{triples_k} = {triples_i} if i = k, k in I and k not in J
{triples_k} = {triples_j} if j = k, k in J and k not in I

GS-DIFF is the same except
{triples_k} = {triples_i} set-difference { triples_j}
if i = k, j = k and k in I and k in J
{triples_k} = {triples_i} if i = k, k in I and k not in J
No { triples_k} if k in J and not I.

Without the auxiliary functions, I found myself having to repeat this
block of definitions which lead to rather large definitions.

4.2.2 DeleteDataOperation
Same except GS-DIFF and mention what happens about any (<i> {}) that arise.

4.2.3 DeleteInsertOperation

Could this be broken up a bit?

P = pattern (WHERE clause)
B = bindings from solve P
D = delete template
I = insert template

X = ({triples}, {(<i> {triples_i})} formed by D(B)
Y = ({triples}, {(<i> {triples_i})} formed by I(B)

OpDeleteInsert(GSS(GS), D, I, P) =
GS-UNION(GS-DIFF(GSS, X), Y)

4.2.4, 4.2.5 similarly.

4.2.6 DeleteWhereOperation

Set D=P, noting the restricted P.