]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/mathql/doc/mathql_introduction_core.tex
ocaml 3.09 transition
[helm.git] / helm / mathql / doc / mathql_introduction_core.tex
index c277f1852918461e2e2848a9d631261eb51b985e..05f9e9fd93f8836e90b6e90c0a676171557a7a28 100644 (file)
 {\MathQL}.4 consists of a core language and of a basic library. Other
 user-defined libraries can be added at will. The core language includes the
 \TT{property} operator mentioned in \subsecref{HighAccess} that queries the
-underlying {\RDF} database and the infrastructure to post-process the
+underlying {\RDF} database, and the infrastructure to post-process the
 query results. The components of this infrastructure are listed below:
 
 \begin{itemize}
 
 \item 
-Explicit sets of attributed values.
-
+\textbf{Explicit sets of attributed values.}
 An explicit {\av} set can be placed in a query in two forms: 
-as a single quoted string, like \verb+"this is a query result"+, that
-evaluates in a single {\av} with that value and no attributes, or as a full
-{\av} set in the syntax shown in the previous sections but sorrounded by
-square brackets, like \verb+["head" attr {"attribute-name" = "contents"}]+.
-\newline
-In the second form, the contents of an attribute can be the result of a query,
-like
-\verb+["head" attr {"attribute-name" = property /"metadata" of "resource"}]+.
+as a quoted string, like \verb+"this is a query result"+, that evaluates in a
+single {\av} with that value and no attributes, or as a full {\av} set in the
+syntax shown in the previous sections but surrounded by square brackets, like 
+\verb+["head" attr {/"attribute" = "contents"}]+.
 \newline
-In this case the contents of the attribute are the head strings of the query
-result, whose attributes (if any) are discarded. 
+In the second form, the contents of an attribute can be the result of a query
+and in this case the contents of the attribute are the head strings of the
+query result, whose attributes (if any) are discarded. 
+\end{itemize}
 
-\item 
-Variable assignment.
+\begin{center}
+\verb+["head" attr {/"attribute" = property /"metadata" of "resource"}]+
+\end{center}
+
+\begin{itemize}
 
+\item 
+\textbf{Variable assignment.}
 Variables for {\av} sets (preceded by a \TT{\$} sign and called
 \emph{set variables}) can be assigned using a standard \emph{let-in}
 construction and may appear wherever an {\av} set ({\ie} a query result) is
 allowed.  
-\newline
 The assignment has the form: 
 \TT{let \$}\EM{variable} \TT{=} \EM{av-set} \TT{in} \EM{av-set}
 so we can write:
 \newline
-\verb+let $var = "contents" in ["head" attr {"attribute-name" = $var}]+.
+\verb+let $var = "contents" in ["head" attr {/"attribute" = $var}]+.
 
-The scope rules of {\MathQL} variables are tipical for an imperative
-programming language and any case of assignment propagation will be indicated.
+The scope of {\MathQL} variables is typical for an imperative programming
+language and any case of assignment propagation will be indicated.
 
 \item 
-Sequential composition.
-
+\textbf{Sequential composition.}
 This construction has the form: \EM{av-set} \TT{;;} \EM{av-set} and works as
 follows: the two {\av} sets are evaluated one after the other and the first
 one is discarded but the variables assigned in the first {\av} set are
 available to the second one.  
 
 \item 
-Unbounded iteration.
-\newline
+\textbf{Unbounded iteration.}
 This construction comes in two forms:
 
-\TT{while} \EM{av-set} \TT{sup} \EM{av-set}:
-\newline
-iterates the evaluation of the second {\av} set until the first {\av set} is
-empty and returns the {\MathQL} set-theoretic union of all the evaluiations
-of the second {\av set}.
-
-\TT{while} \EM{av-set} \TT{inf} \EM{av-set}:
-\newline
-like the former but set-theoretic intersection is used instead of
+\TT{while} \EM{av-set-1} \TT{sup} \EM{av-set-2}:
+iterates the evaluation of \EM{av-set-2} until \EM{av-set-1} is empty and
+returns the {\MathQL} set-theoretic union of all the evaluations of
+\EM{av-set-2}.
+\TT{while} \EM{av-set-1} \TT{inf} \EM{av-set-2}:
+like the former but the set-theoretic intersection is used instead of the
 set-theoretic union.
 
-In order for \TT{while} to work as expected, both {\av} sets are evaluaed in
+In order for \TT{while} to work as expected, both {\av} sets are evaluated in
 a common context during the iteration ({\ie} the variables defined in both
-are alailable to both) and this context is also propagated outside the
-\TT{while} for convenience
+are available to both) and this context is also propagated outside the
+\TT{while}. 
 
 \item 
-Bounded iteration.
-\newline
+\textbf{Bounded iteration.}
 Also this construction comes in two forms:
 
 \TT{for @}\EM{variable} \TT{in} \EM{av-set} \TT{sup} \EM{av-set}:
-\newline
 iterates the evaluation of the second \EM{av-set} assigning the \EM{variable} 
 to each element in the first \EM{av-set} and builds the {\MathQL}
 set-theoretic union of the obtained results.
 
 \TT{for @}\EM{variable} \TT{in} \EM{av-set} \TT{inf} \EM{av-set}:
-\newline
-like the former but set-theoretic intersection is used instead of
+like the former but the set-theoretic intersection is used instead of the
 set-theoretic union.
 
 The variables for attributed values (preceded by a \TT{@} sign and called 
 \emph{element variables}) may appear wherever an {\av} set is allowed and
 and in some additional places. 
-\newline
 The element variables are kept distinct from the set variables (therefore
 \TT{\$variable} and \TT{@variable} may appear in the same query without
-abiguity).
-
+ambiguity).
 Concerning the scope rules used in these constructions, the variables
 assigned by the first {\av} set are available to the second {\av} set during
 the iteration and the variables assigned by both {\av} sets are available 
 outside the \TT{for} as in the previous case. 
 
 \item
-Addition of groups.
-
+\textbf{Addition of groups.}
 \TT{add} \EM{optional-flag} \EM{attribute-groups} \TT{in} \EM{av-set}
-\newline
 builds an {\av} set adding the specified \EM{attribute-groups} to each element
 of the given {\av} set.
 If no \EM{flag} is specified the addition is set-theoretic, whereas with the
@@ -115,22 +104,21 @@ considered.
 
 \figref{Add} shows how to build a one-element {\av} set using \TT{add}.
 
-\begin{figure}[ht]
+\begin{figure}
 \begin{footnotesize} \begin{verbatim}
 The set of attributed values given explicitly:
-["head" attr {"attribute-name" = property /"metadata" of "resource"}]
+ ["head" attr {/"attribute" = property /"metadata" of "resource"}]
 
-The same set built with the add operator
-add {"attribute-name" = property /"metadata" of "resource"} in "head"
+The same set built with the add operator:
+ add {/"attribute" = property /"metadata" of "resource"} in "head"
 \end{verbatim} \end{footnotesize}
-\vskip-1pc
+\vspace{-1pc}
 \caption{A simple use of the add operator}
 \label{Add}
 \end{figure}
 
 \item 
-Existential test.
-
+\textbf{Existential test.}
 The existential test has the form \TT{ex} \EM{av-set} where the
 specification of the {\av} set contains some instances of the construction
 \TT{@}\EM{variable}\TT{.}\EM{attribute-name}, and runs as follows:
@@ -138,15 +126,13 @@ the given {\av} set is evaluated replacing each
 \TT{@}\EM{variable}\TT{.}\EM{attribute-name}
 with the contents of \EM{attribute-name} in an attribute group of the {\av}
 stored in \TT{@}\EM{variable} and the evaluation is repeated for every
-possible choice of the groups (recall that different groups are allowed to
+possible choice of these groups (recall that different groups are allowed to
 contain attributes with the same name). If one evaluation gives a non empty
-result, the defaut representation of \emph{true} is returned (the test
-succeded) in the other case the empty {\av} set, {\ie} \emph{false}, is
-returned (the test failed).
+result, the default representation of \emph{true} is returned, in the other
+case the empty {\av} set, {\ie} \emph{false}, is returned.
 
 \item
-Function invocation:
-
+\textbf{Function invocation.}
 The core language allows to invoke two kinds of external functions (with
 which a language extension may be provided): the functions of the first kind 
 return an {\av} set, the functions of the second kind return a piece of 
@@ -156,23 +142,21 @@ code generator). In particular:
 \EM{function-name} \verb+{+ 
 \EM{name} \TT{,} $\cdots$ \TT{,} \EM{name} \verb+} {+
 \EM{av-set} \TT{,} $\cdots$ \TT{,} \EM{av-set} \verb+}+
-\newline
-invokes the specified function of the firs kind on the given arguments and
-returns it result. The \EM{name} argument are {\MathQL} paths and usually
+invokes a function of the first kind on the given arguments and returns its
+result. The \EM{name} arguments are {\MathQL} paths and usually
 represent attribute names.
 
 \TT{gen} \EM{function-name} \verb+{+
 \EM{av-set} \TT{,} $\cdots$ \TT{,} \EM{av-set} \verb+}+
-\newline
-invokes the specified function of the second kind on the given arguments and
-replaces the function invocation with its result.
+invokes a function of the second kind on the given arguments and replaces
+itself with the function result.
 
-The function names are {\MathQL} paths exactly as the attribute nanes and the 
+The function names are {\MathQL} paths exactly as the attribute names and the 
 graph paths used by the \TT{property} operator. The names of the two kinds of
 functions are kept in distinct environments so they do not clash.
 
 {\MathQL}.4 comes with a basic library of functions of the first kind 
-(see \subsecref{IBasic}) that integrate the core language providing several
-facilities to the user.
+(see \subsecref{Basic}) that integrate the core language providing several
+facilities.
 
 \end{itemize}