]> matita.cs.unibo.it Git - helm.git/blob - helm/mathql/doc/mathql_operational_core.tex
ocaml 3.09 transition
[helm.git] / helm / mathql / doc / mathql_operational_core.tex
1 \subsection {The core language} \label{OCore}
2
3 \subsubsection*{Preliminaries}
4
5 With the above background we are able to type the main objects needed in the
6 formalization:
7
8 \begin{itemize}
9
10 \item
11 A path $ p $ is a list of strings therefore its type is
12 $ T_{0a} = \Listof\ \Str $.
13
14 \item
15 The attribute contents $ V $ are an object of type $ T_{0b} = \Setof\ \Str $.
16
17 \item
18 An attribute group $ G $ is an association set connecting the attribute names
19 to their contents, therefore its type is
20 $ T_1 = \Setof\ (T_{0a} \times T_{0b}) $. 
21
22 \item
23 A head string $ r $ is an object of type $ \Str $.
24
25 \item
26 A set $ A $ of attribute groups is an object of type $ T_2 = \Setof\ T_1 $.  
27
28 \item
29 An {\av}, {\ie} a head string with its attribute groups, has type
30 $ T_3 = \Str \times T_2 $. 
31
32 \item
33 A set $ S $ of {\av}'s is an association set of type $ T_4 = \Setof\ T_3 $.
34
35 \item
36 A triple of an attributed relation is of type
37 $ T_5 = \Str \times \Str \times (T_{0a} \to \Str) $.
38
39 \end{itemize}
40
41 When a constant string appearing in a {\MathQL} expression is unquoted, the
42 surrounding double quotes are deleted and each escaped sequence is translated
43 according to \figref{EscTS}.
44 This operation is formally performed by the function
45 $ \Unquote $ of type $ \Str \to \Str $.
46 Moreover $ \Name \oft \GP{path} \to T_{0a} $ is a helper function that
47 converts a linearized path in its structured representation.
48 Formally $ \Name\ (\TT{/}q_1\TT{/} \cdots \TT{/}q_m) $ 
49 rewrites to $ [\Unquote\ q_1, \cdots, \Unquote\ q_m] $.
50
51 The semantics of {\MathQL} expressions denoting queries is given by the infix
52 relation $ \daq $ that evaluates a query to an {\av} set.
53 These expressions are evaluated in a context $ \G = \g $
54 which is a triple of association sets that connect
55 set variables to {\av} sets, element variables to {\av}'s and element
56 variables to attribute groups.
57 Therefore the type $ K $ of the context $ \G $ is:
58
59 \begin{footnotesize} \begin{center}
60
61 \Setof\ (\GP{svar} \times T_4) \times
62 \Setof\ (\GP{evar} \times T_3) \times % $ \\ $ \times\
63 \Setof\ (\GP{evar} \times T_1)
64 $
65 \end{center} \end{footnotesize}
66
67 \noindent
68 and the evaluating relation is of the following type:
69
70 \begin{footnotesize}
71 \begin{center} \begin{tabular}{l}
72 $ \mathord{\daq} \oft (K \times \GP{query}) \times (K \times T_4) \to \Boole $.
73 \end{tabular} \end{center}
74 \end{footnotesize}
75
76 The context components $ \G_s $ and $ \G_e $ are used to store the contents of
77 variables, while $ \G_g $ is used by the \TT{ex} operator to be presented
78 below.
79
80 In the following we will write $ (\G, x) \daq S $ to abbreviate
81 $ (\G, x) \daq (\G, S) $. 
82
83 The semantics of {\MathQL} expressions denoting results is given by the infix
84 relation $ \dar \oft \GP{avs} \times T_4 \to \Boole $ that evaluates a result
85 to an {\av} set.
86
87 \subsubsection*{Queries}
88
89 The first group of \GP{query} expressions include the representation of
90 explicit {\av} sets and the syntactic grouping facility:
91
92 \begin{itemize}
93
94 \item 
95 The syntactic grouping is obtained enclosing a \GP{query} between \TT{(}
96 and \TT{)}.    
97 An explicit {\av} set can be represented either by a single string, which is
98 converted into a single {\av} with no attributes, or by a \GP{xavs}
99 (extended {\av} set) expression enclosed between \TT{[} and \TT{]}.
100 Such an expression describes all the components of an {\av} set and is
101 evaluated using the rules given below.    
102
103 \begin{footnotesize} 
104 \begin{center} 
105 %
106 \irule{(\G, x) \daq S}{}{(\G, (x)) \daq S} \spc
107 \irule{q \oft \GP{string}}{}{(\G, q) \daq \{(\Unquote\ q, \ES)\}}
108 %
109 \end{center} 
110 \begin{center} 
111 %
112 \irule{x_1, \cdots, x_m \in \GP{xav} \spc 
113        (\G, \TT{[} x_1 \TT{]}) \daq S_1 \spc \cdots \spc (\G, \TT{[} x_m \TT{]}) \daq S_m}{}
114       {(\G, \TT{[} x_1 \TT{;} \cdots \TT{;} x_m \TT{]}) \daq S_1 \ssum \cdots \ssum S_m}
115 %
116 \end{center} 
117 \begin{center} 
118 %
119 \irule{q \in \GP{string} \spc g_1, \cdots, g_m \in \GP{xgroup} \icr
120        (\G, \TT{[} q\ \TT{attr}\ g_1 \TT{]}) \daq S_1 \spc \cdots \spc
121        (\G, \TT{[} q\ \TT{attr}\ g_m \TT{]}) \daq S_m}{}
122       {(\G, \TT{[} q\ \TT{attr}\ g_1 \TT{,} \cdots \TT{,} g_m \TT{]}) \daq S_1 \ssum \cdots \ssum S_m}
123 %
124 \end{center} 
125 \begin{center} 
126 %
127 \irule{q \in \GP{string} \spc a_1, \cdots, a_m \in \GP{xatr} \icr
128        (\G, \TT{[} q\ \TT{attr}\ \{ a_1 \} \TT{]}) \daq S_1 \spc \cdots \spc
129        (\G, \TT{[} q\ \TT{attr}\ \{ a_m \} \TT{]}) \daq S_m}{}
130       {(\G, \TT{[} q\ \TT{attr}\ \{ a_1 \TT{;} \cdots \TT{;} a_m \} \TT{]}) \daq S_1 \dsum \cdots \dsum S_m}
131 %
132 \end{center} 
133 \begin{center} 
134 %
135 \irule{q \in \GP{string} \spc p \in \GP{path} \spc x \daq S}{}
136       {(\G, \TT{[} q\ \TT{attr}\ \{ p = x \} \TT{]}) \daq 
137        \{(\Unquote\ q, \{ \{ (\Name\ p, \Fsts\ S) \} \})\}}
138 %
139 \end{center} 
140 \end{footnotesize}
141
142 $ \dsum $ and $ \ssum $ are helper functions describing the two union
143 operations on {\av} sets: with and without attribute distribution respectively.
144
145 \begin{footnotesize}
146 \begin{center} \begin{tabular}{lrll}
147 %
148 1a &
149 $ (S_1 \sdor \{(r, A_1)\}) \ssum (S_2 \sdor \{(r, A_2)\}) $ & rewrites to &
150 $ (S_1 \ssum S_2) \sor \{(r, A_1 \sor A_2)\} $ \\
151 1b & $ S_1 \ssum S_2 $ & rewrites to & $ S_1 \sor S_2 $ \\ 
152 2a &
153 $ (S_1 \sdor \{(r, A_1)\}) \dsum (S_2 \sdor \{(r, A_2)\}) $ & rewrites to &
154 $ (S_1 \dsum S_2) \sor \{(r, A_1 \distr A_2)\} $ \\
155 2b & $ S_1 \dsum S_2 $ & rewrites to & $ S_1 \sor S_2 $
156 %
157 \end{tabular} \end{center}
158 \end{footnotesize}
159
160 Rules 1a, 2a override 1b, 2b and
161 $ A_1 \distr A_2 = \{G_1 \ssum G_2 \st G_1 \in A_1, G_2 \in A_2\} $.
162
163 \item 
164 The semantics of the \TT{property} operator is described below.
165
166 In the following rule,
167 $s$ is ``$ \TT{property}\ h\ p_1\ \TT{main}\ p_2\ \TT{attr}\ e_1, \cdots,
168 e_m\ \TT{in}\ k\ x $'', $P$ is $ \Property\ h $ and
169 $A_2$ is $ \{ \Exp\ P\ p_1\ r_1\ \{e_1, \cdots, e_m\}\} $:
170
171 \begin{footnotesize}
172 \begin{center}
173 %
174 \irule
175 {h \oft \GP{ref} \spc p_1, p_2 \oft \GP{path} \spc 
176  e_1, \cdots, e_m \oft \GP{exp} \spc k \in \TT{["pattern"]?} \spc 
177  (\G, x) \daq S
178 }{A}
179 {(\G, s) \daq \bigsum \{ \{(r_2, A_2)\} \st  
180 (\lex r_1 \in \Src\ k\ P\ (\Fsts\ S))\ 
181 (r_1, p_1 \app p_2, r_2) \in P
182 \}}
183 %
184 \end{center}
185 \end{footnotesize}
186
187 When the \TT{main} clause is not present, we assume $ p_2 = \TT{/} $.
188
189 Here $ \Property\ h $ gives the appropriate access relation according to
190 the $ h $ flag (this is the primitive function that inspects the {\RDF}
191 graph).
192
193 $ \Src\ k\ P\ V $ is a helper function giving the source set
194 according to the $ k $ flag. $ \Src $ is based on $ \Match $, the helper
195 function handling {\POSIX} regular expressions.
196 Here $ \Pattern\ W\ s $ is the primitive function returning the subset of
197 $ W \oft \Setof\ \Str $ whose element match the {\POSIX} 1003.2-1992%
198 \footnote{In {\POSIX} 1003.1-2001:
199 \CURI{http://www.unix-systems.org/version3/ieee\_\,std.html}.}
200 regular expression $ \verb+"^"+ \app s \app \TT{"\$"} $.
201
202 \begin{footnotesize}
203 \begin{center} \begin{tabular}{rll}
204 %
205 $ \Src\ \TT{""}\ P\ V $ & rewrites to & $ V $ \\
206 $ \Src\ \TT{"pattern"}\ P\ V $ & rewrites to &
207 $ \Match\ \{r_1 \st (\lex p, r2)\ (r_1, p, r_2) \in P\} $\ V \\
208 $ \Match\ W\ V $ & rewrites to & $ \bigsor \{\Pattern\ W\ s \st s \in V\} $
209 %
210 \end{tabular} \end{center}
211 \end{footnotesize}
212
213 $ \Exp\ P\ p_1\ r_1\ E $ is the helper function that builds the group of
214 attributes specified in the \TT{attr} clause.
215 $ \Exp $ is based on $ \Exp\p $ which handles a single attribute. Formally,
216 if $ p, p\p \oft \GP{path} $ and $ E \oft \Setof\ \GP{exp} $:
217
218 \begin{footnotesize}
219 \begin{center} \begin{tabular}{rll}
220 %
221 $ f\ P\ r_1\ p_1\ p $ & rewrites to &
222 $ \{ r_2 \st (r_1, p_1 \app (\Name\ p), r_2) \in P \} $ \\
223 $ \Exp\p\ P\ r_1\ p_1\ p $ & rewrites to &
224 $ \{ (\Name\ p, f\ P\ r_1\ p_1\ p) \} $ \\
225 $ \Exp\p\ P\ r_1\ p_1\ (p\ \TT{as}\ p\p) $ & rewrites to &
226 $ \{ (\Name\ p\p, f\ P\ r_1\ p_1\ p) \} $ \\
227 $ \Exp\ P\ r_1\ p_1\ E $ & rewrites to &
228 $ \bigsum \{ \Exp\p\ P\ r_1\ p_1\ e \st e \in E \} $ \\ 
229 \end{tabular} \end{center}
230 \end{footnotesize}
231
232 When $ c_1, \cdots, c_n \oft \GP{cons} $ and the clause
233 ``\TT{istrue} $ c_1, \cdots, c_n $'' is present, the set $ P $ must be replaced
234 with $ \{ (r_1, p, r_2) \in P \st \Istrue\ P\ r_1\ p_1\ C \} $
235 where $ C $ is $ \{c_1, \cdots, c_n\} $ and $ \Istrue $ is a helper function
236 that checks the constraints in $ C $.
237 $ \Istrue $ is based on $ \Istrue\p $ that handles a single constraint.
238 Formally, if $ p \oft \GP{path} $ and $ (\G, x) \daq S $:
239
240 \begin{footnotesize}
241 \begin{center} \begin{tabular}{rll}
242 %
243 $ g\ P\ p_1\ p $ & rewrites to &
244 $ \{ r_2 \st (\lex r_1)\ (r_1, p_1 \app (\Name\ p), r_2) \in P \} $ \\
245 $ \Istrue\p\ P\ r_1\ p_1\ (p\ \TT{in}\ x) $ & rewrites to &
246 $ (f\ P\ r_1\ p_1\ p) \meet \Fsts\ S $ \\
247 $ \Istrue\p\ P\ r_1\ p_1\ (p\ \TT{match}\ x) $ & rewrites to &
248 $ (f\ P\ r_1\ p_1\ p) \meet \Match\ (g\ P\ p_1\ p)\ (\Fsts\ S) $ \\
249 $ \Istrue\ P\ r_1\ p_1\ C $ & rewrites to &
250 $ (\lall c \in W)\ \Istrue\p\ P\ r_1\ p_1\ c $
251 %
252 \end{tabular} \end{center}
253 \end{footnotesize}
254
255 For each clause ``\TT{isfalse} $ c_1, \cdots, c_n $'' the set $ P $
256 must be replaced with \newline
257 $ \{ (r_1, p, r_2) \in P \st \lnot (\Istrue\ P\ r_1\ p_1\ C) \} $
258 (using the above notation).
259 Note that these substitutions and the former must be composed if necessary.
260
261 If the \TT{inverse} flag is present, also replace the instances of $ P $ in
262 the rule $A$ and in the definition of $ \Src $ with
263 $ \{ (r_2, p, r_1) \st (r_1, p, r_2) \in P \} $.
264
265 \end{itemize}
266
267 The second group of \GP{query} expressions allows the context manipulation:
268
269 \begin{itemize}
270
271 \item
272 The operators for reading variables:
273
274 \begin{footnotesize} \begin{center}
275 %
276 \irule{i \oft \GP{svar}}{}{(\g, i) \daq \get{\G_s}{i}} \spc
277 \irule{i \oft \GP{evar}}{}{(\g, i) \daq \{\get{\G_e}{i}\}}
278 %
279 \end{center} \end{footnotesize}
280
281 $ \get{\G_s}{i} $ and $ \{\get{\G_e}{i}\} $ mean $ \ES $ if $ i $ is not defined.
282
283 \item 
284 The \TT{let} operator assigns a set variable (\GP{svar}):
285
286 \begin{footnotesize} 
287 \begin{center}
288 %
289 \irule{i \oft \GP{svar} \spc (\G_1, x_1) \daq (\g, S_1) \spc
290        ((\set{\G_s}{i}{S_1}, \G_e, \G_g), x_2) \daq (\G_2, S_2)}
291 {}{(\G_1, \TT{let}\ i\ \TT{=}\ x_1\ \TT{in}\ x_2) \daq (\G_2, S_2)} 
292 %
293 \end{center} 
294 \end{footnotesize}
295
296 The sequential composition operator \TT{;;} has the semantics of a \TT{let}
297 introducing a fresh variable, so ``$ x_1\ \TT{;;}\ x_2 $'' rewrites
298 to ``$ \TT{let}\ i\ \TT{=}\ x_1\ \TT{in}\ x_2 $'' where $i$ does not occur in
299 $x_2$.
300
301 \item 
302 The \TT{ex} and ``dot'' operators provide a way to read the attributes stored
303 in element variables.
304 The \TT{ex} (exists) operator gives access to the groups of attributes
305 associated to the {\av}'s in the $ \G_e $ part of the context and does
306 this by loading its $ \G_g $ part, which is used by the ``dot'' operator
307 described below. 
308
309 \TT{ex} is true if the query following it is successful for at least one
310 pool of attribute groups, one for each {\av} in the $ \G_e $ part of the
311 context. Formally we have the rules:
312
313 \begin{footnotesize}
314 \begin{center}
315 %
316 \irule{(\lall \D_g \in \All\ \G_e)\ ((\G_s, \G_e, \G_g + \D_g), y) \daq \F}
317       {1}{(\G, \TT{ex}\ y) \daq \F} \spc
318 \irule{\Nop}{2}{(\G, \TT{ex}\ y) \daq \T} \spc
319 %
320 \end{center}
321 \begin{center}
322 %
323 \irule {i \oft \GP{evar} \spc p \oft \GP{path} \spc \get{\get{\G_g}{i}}{\Name\ p} = \{s_1, \cdots, s_m\}}{}
324        {(\G, i\TT{.}p) \daq \{(s_1, \ES), \cdots, (s_m, \ES)\}}
325 %
326 \end{center}
327 \end{footnotesize}
328
329 where%
330 \footnote{$\D_g$ has the type of $ \G_g $.}
331 $ \All\ \G_e = \{\D_g \st \get{\D_g}{i} = G\ \RM{iff}\ G \in \Snd\ \get{\G_e}{i} \} $,
332 and $ \G = \g $.
333
334 Moreover $ \get{\get{\G_g}{i}}{\Name\ p} $ means $ \ES $
335 if $ i $ or $ \Name\ p $ are not defined where appropriate.
336 Here the first rule has higher precedence than the second one does.
337
338 \end{itemize}
339
340 The third group of \GP{query} expressions allows the {\av} set manipulation:
341
342 \begin{itemize}
343
344 \item
345 The \TT{add} operator adds a given set of attribute groups to the {\av}'s
346 of an {\av} set using a union with or without attribute distribution
347 according to the setting of the \TT{distr} flag.
348
349 \begin{footnotesize} 
350 \begin{center}
351 %
352 \irule
353 {h \in \TT{["distr"]?} \spc a \in \GP{xgroups} \icr 
354  (\G, \TT{[} ""\ \TT{attr}\ a \TT{]}) \daq \{("", A)\} \spc 
355  (\G, x) \daq \{(r_1, A_1), \cdots, (r_m, A_m)\}}{}
356 {(\G, \TT{add}\ a\ \TT{in}\ x) \daq \{(r_1, A_1 \jolly A), \cdots, (r_m, A_m \jolly A)\}}
357 %
358 \end{center}
359 \begin{center}
360 %
361 \irule
362 {h \in \TT{["distr"]?} \spc i \in \GP{evar} \spc  
363  (\g, x) \daq \{(r_1, A_1), \cdots, (r_m, A_m)\}}{}
364 {(\g, \TT{add}\ i\ \TT{in}\ x) \daq \{(r_1, A_1 \jolly \Snd\ \get{\G_e}{i}), \cdots, (r_m, A_m \jolly \Snd\ \get{\G_e}{i})\}}
365 %
366 \end{center}
367 \end{footnotesize}
368
369 Where $ \jolly_{\tt""} = \sor $ and $ \jolly_{\tt"distr"} = \distr $.
370 Moreover $ \Snd\ \get{\G_e}{i} = \ES $ if $i$ is not defined.
371
372 \item
373 The semantics of the \TT{for} operator is given using the {\For} helper
374 function:
375
376 \begin{footnotesize}
377 \begin{center}
378 %
379 \irule{i \oft \GP{evar} \spc (\G, x_1) \daq (\G_1, S_1) \spc h \in \TT{["sup"|"inf"]}}
380 {}{(\G, \TT{for}\ i\ \TT{in}\ x_1\ h\ x_2) \daq \For\ h\ \G_1\ i\ x_2\ S_1}
381 %
382 \end{center} 
383 \begin{center}
384 %
385 \irule{i \oft \GP{evar} \spc x_2 \oft \GP{query}}{}
386       {\For\ h\ \G\ i\ x_2\ \ES\ \RM{rewrites to}\ (\G, \ES)}
387 %
388 \end{center} 
389 \begin{center}
390 %
391 \irule{i \oft \GP{evar} \spc ((\G_s, \set{\G_e}{i}{R}, \G_g), x_2) \daq (\G_2, S_2)}
392       {}{\For\ h\ \G\ i\ x_2\ (S_1 \sdor \{R\})\ \RM{rewrites to}\
393       (\G_2 ,(\Snd\ (\For\ h\ \G_2\ i\ x_2\ S_1)) \jolly_h S_2)} 
394 %
395 \end{center}
396 \end{footnotesize}
397
398 Here we have $ R \oft T_3 $, $ \G = \g $, $ \jolly_{\tt"sup"} = \ssum $ and
399 $ \jolly_{\tt"inf"} = \sprod $.
400
401 $ \dprod $ and $ \sprod $ are helper functions describing the two intersection
402 operations on {\av} sets: with and without attribute distribution respectively.
403 They are dual to $ \dsum $ and $ \ssum $. $ \dprod $ does not appear in this
404 version of {\MathQL} but was used in the earlier versions 
405 \cite{Lor02,GS03,Gui03}.   
406
407 \begin{footnotesize}
408 \begin{center} \begin{tabular}{lrll}
409 %
410 1a &
411 $ (S_1 \sdor \{(r, A_1)\}) \sprod (S_2 \sdor \{(r, A_2)\}) $ & rewrites to &
412 $ (S_1 \sprod S_2) \sor \{(r, A_1 \sor A_2)\} $ \\
413 1b & $ S_1 \sprod S_2 $ & rewrites to & $ \ES $ \\ 
414 2a &
415 $ (S_1 \sdor \{(r, A_1)\}) \dprod (S_2 \sdor \{(r, A_2)\}) $ & rewrites to &
416 $ (S_1 \dprod S_2) \sor \{(r, A_1 \distr A_2)\} $ \\
417 2b & $ S_1 \dprod S_2 $ & rewrites to & $ \ES $
418 %
419 \end{tabular} \end{center}
420 \end{footnotesize}
421
422 As for $ \ssum $ and $ \dsum $, rules 1a, 2a override rules 1b, 2b respectively.
423
424 \item
425 The semantics of the \TT{while} operator is given by the rules below:
426
427 \begin{footnotesize}
428 \begin{center}
429 %
430 \irule{h \in \TT{["sup"|"inf"]} \spc (\G, x_1) \daq (\G_1, \ES)}{1}
431 {(\G, \TT{while}\ x_1\ h\ x_2) \daq (\G_1, \ES)}
432 %
433 \end{center} 
434 \begin{center}
435 %
436 \irule
437 {h \in \TT{["sup"|"inf"]} \spc (\G, x_1) \daq (\G_1, S_1) \spc
438  (\G_1, x_2) \daq (\G_2, S_2) \icr 
439  (\G_2, \TT{while}\ x_1\ h\ x_2) \daq (\G_3, S)}{2}
440 {(\G, \TT{while}\ x_1\ h\ x_2) \daq (\G_3, S_2 \jolly_h S)}
441 %
442 \end{center} 
443 \end{footnotesize}
444
445 Again $ \jolly_{\tt"sup"} = \ssum $ and $ \jolly_{\tt"inf"} = \sprod $.
446 Rule 1 takes precedence over rule 2.
447
448 \end{itemize}
449
450 The forth group of \GP{query} constructions makes {\MathQL} extensible.
451
452 \begin{itemize}
453
454 \item
455 The ``function'' construction invokes an external function returning an {\av}
456 set. The function is identified by a \GP{path} and its arguments are a set of 
457 \GP{path}'s and a set of \GP{query}'s. It is a mistake to invoke a function
458 with the wrong number of \GP{path}'s and \GP{query}'s as input (each
459 particular function defines these numbers independently).
460
461 \begin{footnotesize}
462 \begin{center}
463 %
464 \irule
465 {p, p_1, \cdots, p_m \in \GP{path} \spc x_1, \cdots, x_n \in \GP{query}}{}
466 {(\G, p\ \{p_1 \TT{,} \cdots \TT{,} p_m\}\ \{x_1 \TT{,} \cdots \TT{,} x_m\})
467  \daq \Fun\ p\ [p_1, \cdots, p_m]\ [x_1, \cdots, x_n]\ \G} 
468 %
469 \end{center} 
470 \end{footnotesize}
471
472 where $ \Fun \oft \GP{path} \times (\Listof\ \GP{path}) \times (\Listof\
473 \GP{query}) \times K \to T_4 $ is the primitive function performing the
474 low level invocation. 
475 The core language does not include any external function and it is a mistake
476 to invoke an undefined function.
477
478 \item
479 The \TT{gen} construction invokes an external function returning a \GP{query}.
480 The function is identified by a \GP{path} and its arguments are a set of 
481 \GP{query}'s. It is a mistake to invoke a function with the wrong number of
482 \GP{query}'s as input (each particular function defines this number
483 independently).
484
485 \begin{footnotesize}
486 \begin{center}
487 %
488 \irule
489 {p \in \GP{path} \spc x_1, \cdots, x_n \in \GP{query} \spc 
490  (\G, \Gen\ p\ [x_1, \cdots, x_n]\ \G) \daq (\G\p, S)}{}
491 {(\G, \TT{gen}\ p\ \{x_1 \TT{,} \cdots \TT{,} x_m\}) \daq (\G\p, S)} 
492 %
493 \end{center} 
494 \end{footnotesize}
495
496 where $ \Gen \oft \GP{path} \times (\Listof\ \GP{query}) \times K \to
497 \GP{query} $ is the primitive function performing the low level invocation. 
498 The core language does not include any external function of this kind and it
499 is a mistake to invoke an undefined function.
500 The construction ``\TT{gen} p \TT{in} x'' rewrites to ``\TT{gen} p \verb+{+x\verb+}+''.
501
502 \end{itemize}
503
504 \subsubsection*{Results}
505
506 An \GP{avs} expression (the explicit representation of an {\av} set denoting a
507 query result) is evaluated to an {\av} set according to the following rules.
508
509 \begin{footnotesize}
510 \begin{center} 
511 %
512 \irule{x_1, \cdots, x_m \in \GP{av} \spc 
513        x_1 \dar S_1 \spc \cdots \spc x_m \dar S_m}{}
514       {x_1 \TT{;} \cdots \TT{;} x_m \dar S_1 \ssum \cdots \ssum S_m}
515 %
516 \end{center} 
517 \begin{center} 
518 %
519 \irule{q \in \GP{string} \spc g_1, \cdots, g_m \in \GP{group} \spc
520        q\ \TT{attr}\ g_1 \dar S_1 \spc \cdots \spc
521        q\ \TT{attr}\ g_m \dar S_m}{}
522       {q\ \TT{attr}\ g_1 \TT{,} \cdots \TT{,} g_m \dar S_1 \ssum \cdots \ssum S_m}
523 %
524 \end{center} 
525 \begin{center} 
526 %
527 \irule{q \in \GP{string} \spc a_1, \cdots, a_m \in \GP{atr} \spc
528        q\ \TT{attr}\ \{ a_1 \} \dar S_1 \spc \cdots \spc
529        q\ \TT{attr}\ \{ a_m \} \dar S_m}{}
530       {(\G, q\ \TT{attr}\ \{ a_1 \TT{;} \cdots \TT{;} a_m \} \dar S_1 \dsum \cdots \dsum S_m}
531 %
532 \end{center} 
533 \begin{center} 
534 %
535 \irule{q, q_0 \in \GP{string} \spc p \in \GP{path}}{}
536       {q\ \TT{attr}\ \{ p = q_0 \} \dar 
537        \{(\Unquote\ q, \{ \{ (\Name\ p, \{ \Unquote\ q_0 \}) \} \})\}}
538 %
539 \end{center} 
540 \begin{center} 
541 %
542 \irule{q, q_1, \cdots, q_m \in \GP{string} \spc p \in \GP{path}}{}
543       {q\ \TT{attr}\ \{ p = \{ q_1 \TT{,} \cdots \TT{,} q_m \} \} \dar 
544        \{(\Unquote\ q, \{ \{ (\Name\ p, \{ \Unquote\ q_1, \cdots, \Unquote\ q_m \}) \} \})\}}
545 %
546 \end{center} 
547 \end{footnotesize}