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