--- /dev/null
+requires="helm-urimanager"
+version="1.3"
+archive(byte)="mathql.cma"
+archive(native)="mathql.cmxa"
+linkopts=""
--- /dev/null
+requires="helm-cic helm-cic_proof_checking helm-mathql"
+version="1.3"
+archive(byte)="mathql_generator.cma"
+archive(native)="mathql_generator.cmxa"
+linkopts=""
--- /dev/null
+requires="helm-cic postgres mysql helm-mathql helm-registry"
+#natile-galax
+version="1.3"
+archive(byte)="mathql_interpreter.cma"
+archive(native)="mathql_interpreter.cmxa"
+linkopts=""
--- /dev/null
+*.dvi *.aux *.log *.ps *.gz *.toc
--- /dev/null
+% LLNCS DOCUMENT CLASS -- version 2.13 (28-Jan-2002)
+% Springer Verlag LaTeX2e support for Lecture Notes in Computer Science
+%
+%%
+%% \CharacterTable
+%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+%% Digits \0\1\2\3\4\5\6\7\8\9
+%% Exclamation \! Double quote \" Hash (number) \#
+%% Dollar \$ Percent \% Ampersand \&
+%% Acute accent \' Left paren \( Right paren \)
+%% Asterisk \* Plus \+ Comma \,
+%% Minus \- Point \. Solidus \/
+%% Colon \: Semicolon \; Less than \<
+%% Equals \= Greater than \> Question mark \?
+%% Commercial at \@ Left bracket \[ Backslash \\
+%% Right bracket \] Circumflex \^ Underscore \_
+%% Grave accent \` Left brace \{ Vertical bar \|
+%% Right brace \} Tilde \~}
+%%
+\NeedsTeXFormat{LaTeX2e}[1995/12/01]
+\ProvidesClass{llncs}[2002/01/28 v2.13
+^^J LaTeX document class for Lecture Notes in Computer Science]
+% Options
+\let\if@envcntreset\iffalse
+\DeclareOption{envcountreset}{\let\if@envcntreset\iftrue}
+\DeclareOption{citeauthoryear}{\let\citeauthoryear=Y}
+\DeclareOption{oribibl}{\let\oribibl=Y}
+\let\if@custvec\iftrue
+\DeclareOption{orivec}{\let\if@custvec\iffalse}
+\let\if@envcntsame\iffalse
+\DeclareOption{envcountsame}{\let\if@envcntsame\iftrue}
+\let\if@envcntsect\iffalse
+\DeclareOption{envcountsect}{\let\if@envcntsect\iftrue}
+\let\if@runhead\iffalse
+\DeclareOption{runningheads}{\let\if@runhead\iftrue}
+
+\let\if@openbib\iffalse
+\DeclareOption{openbib}{\let\if@openbib\iftrue}
+
+% languages
+\let\switcht@@therlang\relax
+\def\ds@deutsch{\def\switcht@@therlang{\switcht@deutsch}}
+\def\ds@francais{\def\switcht@@therlang{\switcht@francais}}
+
+\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
+
+\ProcessOptions
+
+\LoadClass[twoside]{article}
+\RequirePackage{multicol} % needed for the list of participants, index
+
+\setlength{\textwidth}{12.2cm}
+\setlength{\textheight}{19.3cm}
+\renewcommand\@pnumwidth{2em}
+\renewcommand\@tocrmarg{3.5em}
+%
+\def\@dottedtocline#1#2#3#4#5{%
+ \ifnum #1>\c@tocdepth \else
+ \vskip \z@ \@plus.2\p@
+ {\leftskip #2\relax \rightskip \@tocrmarg \advance\rightskip by 0pt plus 2cm
+ \parfillskip -\rightskip \pretolerance=10000
+ \parindent #2\relax\@afterindenttrue
+ \interlinepenalty\@M
+ \leavevmode
+ \@tempdima #3\relax
+ \advance\leftskip \@tempdima \null\nobreak\hskip -\leftskip
+ {#4}\nobreak
+ \leaders\hbox{$\m@th
+ \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
+ mu$}\hfill
+ \nobreak
+ \hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #5}%
+ \par}%
+ \fi}
+%
+\def\switcht@albion{%
+\def\abstractname{Abstract.}
+\def\ackname{Acknowledgement.}
+\def\andname{and}
+\def\lastandname{\unskip, and}
+\def\appendixname{Appendix}
+\def\chaptername{Chapter}
+\def\claimname{Claim}
+\def\conjecturename{Conjecture}
+\def\contentsname{Table of Contents}
+\def\corollaryname{Corollary}
+\def\definitionname{Definition}
+\def\examplename{Example}
+\def\exercisename{Exercise}
+\def\figurename{Fig.}
+\def\keywordname{{\bf Key words:}}
+\def\indexname{Index}
+\def\lemmaname{Lemma}
+\def\contriblistname{List of Contributors}
+\def\listfigurename{List of Figures}
+\def\listtablename{List of Tables}
+\def\mailname{{\it Correspondence to\/}:}
+\def\noteaddname{Note added in proof}
+\def\notename{Note}
+\def\partname{Part}
+\def\problemname{Problem}
+\def\proofname{Proof}
+\def\propertyname{Property}
+\def\propositionname{Proposition}
+\def\questionname{Question}
+\def\remarkname{Remark}
+\def\seename{see}
+\def\solutionname{Solution}
+\def\subclassname{{\it Subject Classifications\/}:}
+\def\tablename{Table}
+\def\theoremname{Theorem}}
+\switcht@albion
+% Names of theorem like environments are already defined
+% but must be translated if another language is chosen
+%
+% French section
+\def\switcht@francais{%\typeout{On parle francais.}%
+ \def\abstractname{R\'esum\'e.}%
+ \def\ackname{Remerciements.}%
+ \def\andname{et}%
+ \def\lastandname{ et}%
+ \def\appendixname{Appendice}
+ \def\chaptername{Chapitre}%
+ \def\claimname{Pr\'etention}%
+ \def\conjecturename{Hypoth\`ese}%
+ \def\contentsname{Table des mati\`eres}%
+ \def\corollaryname{Corollaire}%
+ \def\definitionname{D\'efinition}%
+ \def\examplename{Exemple}%
+ \def\exercisename{Exercice}%
+ \def\figurename{Fig.}%
+ \def\keywordname{{\bf Mots-cl\'e:}}
+ \def\indexname{Index}
+ \def\lemmaname{Lemme}%
+ \def\contriblistname{Liste des contributeurs}
+ \def\listfigurename{Liste des figures}%
+ \def\listtablename{Liste des tables}%
+ \def\mailname{{\it Correspondence to\/}:}
+ \def\noteaddname{Note ajout\'ee \`a l'\'epreuve}%
+ \def\notename{Remarque}%
+ \def\partname{Partie}%
+ \def\problemname{Probl\`eme}%
+ \def\proofname{Preuve}%
+ \def\propertyname{Caract\'eristique}%
+%\def\propositionname{Proposition}%
+ \def\questionname{Question}%
+ \def\remarkname{Remarque}%
+ \def\seename{voir}
+ \def\solutionname{Solution}%
+ \def\subclassname{{\it Subject Classifications\/}:}
+ \def\tablename{Tableau}%
+ \def\theoremname{Th\'eor\`eme}%
+}
+%
+% German section
+\def\switcht@deutsch{%\typeout{Man spricht deutsch.}%
+ \def\abstractname{Zusammenfassung.}%
+ \def\ackname{Danksagung.}%
+ \def\andname{und}%
+ \def\lastandname{ und}%
+ \def\appendixname{Anhang}%
+ \def\chaptername{Kapitel}%
+ \def\claimname{Behauptung}%
+ \def\conjecturename{Hypothese}%
+ \def\contentsname{Inhaltsverzeichnis}%
+ \def\corollaryname{Korollar}%
+%\def\definitionname{Definition}%
+ \def\examplename{Beispiel}%
+ \def\exercisename{\"Ubung}%
+ \def\figurename{Abb.}%
+ \def\keywordname{{\bf Schl\"usselw\"orter:}}
+ \def\indexname{Index}
+%\def\lemmaname{Lemma}%
+ \def\contriblistname{Mitarbeiter}
+ \def\listfigurename{Abbildungsverzeichnis}%
+ \def\listtablename{Tabellenverzeichnis}%
+ \def\mailname{{\it Correspondence to\/}:}
+ \def\noteaddname{Nachtrag}%
+ \def\notename{Anmerkung}%
+ \def\partname{Teil}%
+%\def\problemname{Problem}%
+ \def\proofname{Beweis}%
+ \def\propertyname{Eigenschaft}%
+%\def\propositionname{Proposition}%
+ \def\questionname{Frage}%
+ \def\remarkname{Anmerkung}%
+ \def\seename{siehe}
+ \def\solutionname{L\"osung}%
+ \def\subclassname{{\it Subject Classifications\/}:}
+ \def\tablename{Tabelle}%
+%\def\theoremname{Theorem}%
+}
+
+% Ragged bottom for the actual page
+\def\thisbottomragged{\def\@textbottom{\vskip\z@ plus.0001fil
+\global\let\@textbottom\relax}}
+
+\renewcommand\small{%
+ \@setfontsize\small\@ixpt{11}%
+ \abovedisplayskip 8.5\p@ \@plus3\p@ \@minus4\p@
+ \abovedisplayshortskip \z@ \@plus2\p@
+ \belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@
+ \def\@listi{\leftmargin\leftmargini
+ \parsep 0\p@ \@plus1\p@ \@minus\p@
+ \topsep 8\p@ \@plus2\p@ \@minus4\p@
+ \itemsep0\p@}%
+ \belowdisplayskip \abovedisplayskip
+}
+
+\frenchspacing
+\widowpenalty=10000
+\clubpenalty=10000
+
+\setlength\oddsidemargin {63\p@}
+\setlength\evensidemargin {63\p@}
+\setlength\marginparwidth {90\p@}
+
+\setlength\headsep {16\p@}
+
+\setlength\footnotesep{7.7\p@}
+\setlength\textfloatsep{8mm\@plus 2\p@ \@minus 4\p@}
+\setlength\intextsep {8mm\@plus 2\p@ \@minus 2\p@}
+
+\setcounter{secnumdepth}{2}
+
+\newcounter {chapter}
+\renewcommand\thechapter {\@arabic\c@chapter}
+
+\newif\if@mainmatter \@mainmattertrue
+\newcommand\frontmatter{\cleardoublepage
+ \@mainmatterfalse\pagenumbering{Roman}}
+\newcommand\mainmatter{\cleardoublepage
+ \@mainmattertrue\pagenumbering{arabic}}
+\newcommand\backmatter{\if@openright\cleardoublepage\else\clearpage\fi
+ \@mainmatterfalse}
+
+\renewcommand\part{\cleardoublepage
+ \thispagestyle{empty}%
+ \if@twocolumn
+ \onecolumn
+ \@tempswatrue
+ \else
+ \@tempswafalse
+ \fi
+ \null\vfil
+ \secdef\@part\@spart}
+
+\def\@part[#1]#2{%
+ \ifnum \c@secnumdepth >-2\relax
+ \refstepcounter{part}%
+ \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
+ \else
+ \addcontentsline{toc}{part}{#1}%
+ \fi
+ \markboth{}{}%
+ {\centering
+ \interlinepenalty \@M
+ \normalfont
+ \ifnum \c@secnumdepth >-2\relax
+ \huge\bfseries \partname~\thepart
+ \par
+ \vskip 20\p@
+ \fi
+ \Huge \bfseries #2\par}%
+ \@endpart}
+\def\@spart#1{%
+ {\centering
+ \interlinepenalty \@M
+ \normalfont
+ \Huge \bfseries #1\par}%
+ \@endpart}
+\def\@endpart{\vfil\newpage
+ \if@twoside
+ \null
+ \thispagestyle{empty}%
+ \newpage
+ \fi
+ \if@tempswa
+ \twocolumn
+ \fi}
+
+\newcommand\chapter{\clearpage
+ \thispagestyle{empty}%
+ \global\@topnum\z@
+ \@afterindentfalse
+ \secdef\@chapter\@schapter}
+\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
+ \if@mainmatter
+ \refstepcounter{chapter}%
+ \typeout{\@chapapp\space\thechapter.}%
+ \addcontentsline{toc}{chapter}%
+ {\protect\numberline{\thechapter}#1}%
+ \else
+ \addcontentsline{toc}{chapter}{#1}%
+ \fi
+ \else
+ \addcontentsline{toc}{chapter}{#1}%
+ \fi
+ \chaptermark{#1}%
+ \addtocontents{lof}{\protect\addvspace{10\p@}}%
+ \addtocontents{lot}{\protect\addvspace{10\p@}}%
+ \if@twocolumn
+ \@topnewpage[\@makechapterhead{#2}]%
+ \else
+ \@makechapterhead{#2}%
+ \@afterheading
+ \fi}
+\def\@makechapterhead#1{%
+% \vspace*{50\p@}%
+ {\centering
+ \ifnum \c@secnumdepth >\m@ne
+ \if@mainmatter
+ \large\bfseries \@chapapp{} \thechapter
+ \par\nobreak
+ \vskip 20\p@
+ \fi
+ \fi
+ \interlinepenalty\@M
+ \Large \bfseries #1\par\nobreak
+ \vskip 40\p@
+ }}
+\def\@schapter#1{\if@twocolumn
+ \@topnewpage[\@makeschapterhead{#1}]%
+ \else
+ \@makeschapterhead{#1}%
+ \@afterheading
+ \fi}
+\def\@makeschapterhead#1{%
+% \vspace*{50\p@}%
+ {\centering
+ \normalfont
+ \interlinepenalty\@M
+ \Large \bfseries #1\par\nobreak
+ \vskip 40\p@
+ }}
+
+\renewcommand\section{\@startsection{section}{1}{\z@}%
+ {-18\p@ \@plus -4\p@ \@minus -4\p@}%
+ {12\p@ \@plus 4\p@ \@minus 4\p@}%
+ {\normalfont\large\bfseries\boldmath
+ \rightskip=\z@ \@plus 8em\pretolerance=10000 }}
+\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
+ {-18\p@ \@plus -4\p@ \@minus -4\p@}%
+ {8\p@ \@plus 4\p@ \@minus 4\p@}%
+ {\normalfont\normalsize\bfseries\boldmath
+ \rightskip=\z@ \@plus 8em\pretolerance=10000 }}
+\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
+ {-18\p@ \@plus -4\p@ \@minus -4\p@}%
+ {-0.5em \@plus -0.22em \@minus -0.1em}%
+ {\normalfont\normalsize\bfseries\boldmath}}
+\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
+ {-12\p@ \@plus -4\p@ \@minus -4\p@}%
+ {-0.5em \@plus -0.22em \@minus -0.1em}%
+ {\normalfont\normalsize\itshape}}
+\renewcommand\subparagraph[1]{\typeout{LLNCS warning: You should not use
+ \string\subparagraph\space with this class}\vskip0.5cm
+You should not use \verb|\subparagraph| with this class.\vskip0.5cm}
+
+\DeclareMathSymbol{\Gamma}{\mathalpha}{letters}{"00}
+\DeclareMathSymbol{\Delta}{\mathalpha}{letters}{"01}
+\DeclareMathSymbol{\Theta}{\mathalpha}{letters}{"02}
+\DeclareMathSymbol{\Lambda}{\mathalpha}{letters}{"03}
+\DeclareMathSymbol{\Xi}{\mathalpha}{letters}{"04}
+\DeclareMathSymbol{\Pi}{\mathalpha}{letters}{"05}
+\DeclareMathSymbol{\Sigma}{\mathalpha}{letters}{"06}
+\DeclareMathSymbol{\Upsilon}{\mathalpha}{letters}{"07}
+\DeclareMathSymbol{\Phi}{\mathalpha}{letters}{"08}
+\DeclareMathSymbol{\Psi}{\mathalpha}{letters}{"09}
+\DeclareMathSymbol{\Omega}{\mathalpha}{letters}{"0A}
+
+\let\footnotesize\small
+
+\if@custvec
+\def\vec#1{\mathchoice{\mbox{\boldmath$\displaystyle#1$}}
+{\mbox{\boldmath$\textstyle#1$}}
+{\mbox{\boldmath$\scriptstyle#1$}}
+{\mbox{\boldmath$\scriptscriptstyle#1$}}}
+\fi
+
+\def\squareforqed{\hbox{\rlap{$\sqcap$}$\sqcup$}}
+\def\qed{\ifmmode\squareforqed\else{\unskip\nobreak\hfil
+\penalty50\hskip1em\null\nobreak\hfil\squareforqed
+\parfillskip=0pt\finalhyphendemerits=0\endgraf}\fi}
+
+\def\getsto{\mathrel{\mathchoice {\vcenter{\offinterlineskip
+\halign{\hfil
+$\displaystyle##$\hfil\cr\gets\cr\to\cr}}}
+{\vcenter{\offinterlineskip\halign{\hfil$\textstyle##$\hfil\cr\gets
+\cr\to\cr}}}
+{\vcenter{\offinterlineskip\halign{\hfil$\scriptstyle##$\hfil\cr\gets
+\cr\to\cr}}}
+{\vcenter{\offinterlineskip\halign{\hfil$\scriptscriptstyle##$\hfil\cr
+\gets\cr\to\cr}}}}}
+\def\lid{\mathrel{\mathchoice {\vcenter{\offinterlineskip\halign{\hfil
+$\displaystyle##$\hfil\cr<\cr\noalign{\vskip1.2pt}=\cr}}}
+{\vcenter{\offinterlineskip\halign{\hfil$\textstyle##$\hfil\cr<\cr
+\noalign{\vskip1.2pt}=\cr}}}
+{\vcenter{\offinterlineskip\halign{\hfil$\scriptstyle##$\hfil\cr<\cr
+\noalign{\vskip1pt}=\cr}}}
+{\vcenter{\offinterlineskip\halign{\hfil$\scriptscriptstyle##$\hfil\cr
+<\cr
+\noalign{\vskip0.9pt}=\cr}}}}}
+\def\gid{\mathrel{\mathchoice {\vcenter{\offinterlineskip\halign{\hfil
+$\displaystyle##$\hfil\cr>\cr\noalign{\vskip1.2pt}=\cr}}}
+{\vcenter{\offinterlineskip\halign{\hfil$\textstyle##$\hfil\cr>\cr
+\noalign{\vskip1.2pt}=\cr}}}
+{\vcenter{\offinterlineskip\halign{\hfil$\scriptstyle##$\hfil\cr>\cr
+\noalign{\vskip1pt}=\cr}}}
+{\vcenter{\offinterlineskip\halign{\hfil$\scriptscriptstyle##$\hfil\cr
+>\cr
+\noalign{\vskip0.9pt}=\cr}}}}}
+\def\grole{\mathrel{\mathchoice {\vcenter{\offinterlineskip
+\halign{\hfil
+$\displaystyle##$\hfil\cr>\cr\noalign{\vskip-1pt}<\cr}}}
+{\vcenter{\offinterlineskip\halign{\hfil$\textstyle##$\hfil\cr
+>\cr\noalign{\vskip-1pt}<\cr}}}
+{\vcenter{\offinterlineskip\halign{\hfil$\scriptstyle##$\hfil\cr
+>\cr\noalign{\vskip-0.8pt}<\cr}}}
+{\vcenter{\offinterlineskip\halign{\hfil$\scriptscriptstyle##$\hfil\cr
+>\cr\noalign{\vskip-0.3pt}<\cr}}}}}
+\def\bbbr{{\rm I\!R}} %reelle Zahlen
+\def\bbbm{{\rm I\!M}}
+\def\bbbn{{\rm I\!N}} %natuerliche Zahlen
+\def\bbbf{{\rm I\!F}}
+\def\bbbh{{\rm I\!H}}
+\def\bbbk{{\rm I\!K}}
+\def\bbbp{{\rm I\!P}}
+\def\bbbone{{\mathchoice {\rm 1\mskip-4mu l} {\rm 1\mskip-4mu l}
+{\rm 1\mskip-4.5mu l} {\rm 1\mskip-5mu l}}}
+\def\bbbc{{\mathchoice {\setbox0=\hbox{$\displaystyle\rm C$}\hbox{\hbox
+to0pt{\kern0.4\wd0\vrule height0.9\ht0\hss}\box0}}
+{\setbox0=\hbox{$\textstyle\rm C$}\hbox{\hbox
+to0pt{\kern0.4\wd0\vrule height0.9\ht0\hss}\box0}}
+{\setbox0=\hbox{$\scriptstyle\rm C$}\hbox{\hbox
+to0pt{\kern0.4\wd0\vrule height0.9\ht0\hss}\box0}}
+{\setbox0=\hbox{$\scriptscriptstyle\rm C$}\hbox{\hbox
+to0pt{\kern0.4\wd0\vrule height0.9\ht0\hss}\box0}}}}
+\def\bbbq{{\mathchoice {\setbox0=\hbox{$\displaystyle\rm
+Q$}\hbox{\raise
+0.15\ht0\hbox to0pt{\kern0.4\wd0\vrule height0.8\ht0\hss}\box0}}
+{\setbox0=\hbox{$\textstyle\rm Q$}\hbox{\raise
+0.15\ht0\hbox to0pt{\kern0.4\wd0\vrule height0.8\ht0\hss}\box0}}
+{\setbox0=\hbox{$\scriptstyle\rm Q$}\hbox{\raise
+0.15\ht0\hbox to0pt{\kern0.4\wd0\vrule height0.7\ht0\hss}\box0}}
+{\setbox0=\hbox{$\scriptscriptstyle\rm Q$}\hbox{\raise
+0.15\ht0\hbox to0pt{\kern0.4\wd0\vrule height0.7\ht0\hss}\box0}}}}
+\def\bbbt{{\mathchoice {\setbox0=\hbox{$\displaystyle\rm
+T$}\hbox{\hbox to0pt{\kern0.3\wd0\vrule height0.9\ht0\hss}\box0}}
+{\setbox0=\hbox{$\textstyle\rm T$}\hbox{\hbox
+to0pt{\kern0.3\wd0\vrule height0.9\ht0\hss}\box0}}
+{\setbox0=\hbox{$\scriptstyle\rm T$}\hbox{\hbox
+to0pt{\kern0.3\wd0\vrule height0.9\ht0\hss}\box0}}
+{\setbox0=\hbox{$\scriptscriptstyle\rm T$}\hbox{\hbox
+to0pt{\kern0.3\wd0\vrule height0.9\ht0\hss}\box0}}}}
+\def\bbbs{{\mathchoice
+{\setbox0=\hbox{$\displaystyle \rm S$}\hbox{\raise0.5\ht0\hbox
+to0pt{\kern0.35\wd0\vrule height0.45\ht0\hss}\hbox
+to0pt{\kern0.55\wd0\vrule height0.5\ht0\hss}\box0}}
+{\setbox0=\hbox{$\textstyle \rm S$}\hbox{\raise0.5\ht0\hbox
+to0pt{\kern0.35\wd0\vrule height0.45\ht0\hss}\hbox
+to0pt{\kern0.55\wd0\vrule height0.5\ht0\hss}\box0}}
+{\setbox0=\hbox{$\scriptstyle \rm S$}\hbox{\raise0.5\ht0\hbox
+to0pt{\kern0.35\wd0\vrule height0.45\ht0\hss}\raise0.05\ht0\hbox
+to0pt{\kern0.5\wd0\vrule height0.45\ht0\hss}\box0}}
+{\setbox0=\hbox{$\scriptscriptstyle\rm S$}\hbox{\raise0.5\ht0\hbox
+to0pt{\kern0.4\wd0\vrule height0.45\ht0\hss}\raise0.05\ht0\hbox
+to0pt{\kern0.55\wd0\vrule height0.45\ht0\hss}\box0}}}}
+\def\bbbz{{\mathchoice {\hbox{$\mathsf\textstyle Z\kern-0.4em Z$}}
+{\hbox{$\mathsf\textstyle Z\kern-0.4em Z$}}
+{\hbox{$\mathsf\scriptstyle Z\kern-0.3em Z$}}
+{\hbox{$\mathsf\scriptscriptstyle Z\kern-0.2em Z$}}}}
+
+\let\ts\,
+
+\setlength\leftmargini {17\p@}
+\setlength\leftmargin {\leftmargini}
+\setlength\leftmarginii {\leftmargini}
+\setlength\leftmarginiii {\leftmargini}
+\setlength\leftmarginiv {\leftmargini}
+\setlength \labelsep {.5em}
+\setlength \labelwidth{\leftmargini}
+\addtolength\labelwidth{-\labelsep}
+
+\def\@listI{\leftmargin\leftmargini
+ \parsep 0\p@ \@plus1\p@ \@minus\p@
+ \topsep 8\p@ \@plus2\p@ \@minus4\p@
+ \itemsep0\p@}
+\let\@listi\@listI
+\@listi
+\def\@listii {\leftmargin\leftmarginii
+ \labelwidth\leftmarginii
+ \advance\labelwidth-\labelsep
+ \topsep 0\p@ \@plus2\p@ \@minus\p@}
+\def\@listiii{\leftmargin\leftmarginiii
+ \labelwidth\leftmarginiii
+ \advance\labelwidth-\labelsep
+ \topsep 0\p@ \@plus\p@\@minus\p@
+ \parsep \z@
+ \partopsep \p@ \@plus\z@ \@minus\p@}
+
+\renewcommand\labelitemi{\normalfont\bfseries --}
+\renewcommand\labelitemii{$\m@th\bullet$}
+
+\setlength\arraycolsep{1.4\p@}
+\setlength\tabcolsep{1.4\p@}
+
+\def\tableofcontents{\chapter*{\contentsname\@mkboth{{\contentsname}}%
+ {{\contentsname}}}
+ \def\authcount##1{\setcounter{auco}{##1}\setcounter{@auth}{1}}
+ \def\lastand{\ifnum\value{auco}=2\relax
+ \unskip{} \andname\
+ \else
+ \unskip \lastandname\
+ \fi}%
+ \def\and{\stepcounter{@auth}\relax
+ \ifnum\value{@auth}=\value{auco}%
+ \lastand
+ \else
+ \unskip,
+ \fi}%
+ \@starttoc{toc}\if@restonecol\twocolumn\fi}
+
+\def\l@part#1#2{\addpenalty{\@secpenalty}%
+ \addvspace{2em plus\p@}% % space above part line
+ \begingroup
+ \parindent \z@
+ \rightskip \z@ plus 5em
+ \hrule\vskip5pt
+ \large % same size as for a contribution heading
+ \bfseries\boldmath % set line in boldface
+ \leavevmode % TeX command to enter horizontal mode.
+ #1\par
+ \vskip5pt
+ \hrule
+ \vskip1pt
+ \nobreak % Never break after part entry
+ \endgroup}
+
+\def\@dotsep{2}
+
+\def\hyperhrefextend{\ifx\hyper@anchor\@undefined\else
+{chapter.\thechapter}\fi}
+
+\def\addnumcontentsmark#1#2#3{%
+\addtocontents{#1}{\protect\contentsline{#2}{\protect\numberline
+ {\thechapter}#3}{\thepage}\hyperhrefextend}}
+\def\addcontentsmark#1#2#3{%
+\addtocontents{#1}{\protect\contentsline{#2}{#3}{\thepage}\hyperhrefextend}}
+\def\addcontentsmarkwop#1#2#3{%
+\addtocontents{#1}{\protect\contentsline{#2}{#3}{0}\hyperhrefextend}}
+
+\def\@adcmk[#1]{\ifcase #1 \or
+\def\@gtempa{\addnumcontentsmark}%
+ \or \def\@gtempa{\addcontentsmark}%
+ \or \def\@gtempa{\addcontentsmarkwop}%
+ \fi\@gtempa{toc}{chapter}}
+\def\addtocmark{\@ifnextchar[{\@adcmk}{\@adcmk[3]}}
+
+\def\l@chapter#1#2{\addpenalty{-\@highpenalty}
+ \vskip 1.0em plus 1pt \@tempdima 1.5em \begingroup
+ \parindent \z@ \rightskip \@tocrmarg
+ \advance\rightskip by 0pt plus 2cm
+ \parfillskip -\rightskip \pretolerance=10000
+ \leavevmode \advance\leftskip\@tempdima \hskip -\leftskip
+ {\large\bfseries\boldmath#1}\ifx0#2\hfil\null
+ \else
+ \nobreak
+ \leaders\hbox{$\m@th \mkern \@dotsep mu.\mkern
+ \@dotsep mu$}\hfill
+ \nobreak\hbox to\@pnumwidth{\hss #2}%
+ \fi\par
+ \penalty\@highpenalty \endgroup}
+
+\def\l@title#1#2{\addpenalty{-\@highpenalty}
+ \addvspace{8pt plus 1pt}
+ \@tempdima \z@
+ \begingroup
+ \parindent \z@ \rightskip \@tocrmarg
+ \advance\rightskip by 0pt plus 2cm
+ \parfillskip -\rightskip \pretolerance=10000
+ \leavevmode \advance\leftskip\@tempdima \hskip -\leftskip
+ #1\nobreak
+ \leaders\hbox{$\m@th \mkern \@dotsep mu.\mkern
+ \@dotsep mu$}\hfill
+ \nobreak\hbox to\@pnumwidth{\hss #2}\par
+ \penalty\@highpenalty \endgroup}
+
+\def\l@author#1#2{\addpenalty{\@highpenalty}
+ \@tempdima=\z@ %15\p@
+ \begingroup
+ \parindent \z@ \rightskip \@tocrmarg
+ \advance\rightskip by 0pt plus 2cm
+ \pretolerance=10000
+ \leavevmode \advance\leftskip\@tempdima %\hskip -\leftskip
+ \textit{#1}\par
+ \penalty\@highpenalty \endgroup}
+
+\setcounter{tocdepth}{0}
+\newdimen\tocchpnum
+\newdimen\tocsecnum
+\newdimen\tocsectotal
+\newdimen\tocsubsecnum
+\newdimen\tocsubsectotal
+\newdimen\tocsubsubsecnum
+\newdimen\tocsubsubsectotal
+\newdimen\tocparanum
+\newdimen\tocparatotal
+\newdimen\tocsubparanum
+\tocchpnum=\z@ % no chapter numbers
+\tocsecnum=15\p@ % section 88. plus 2.222pt
+\tocsubsecnum=23\p@ % subsection 88.8 plus 2.222pt
+\tocsubsubsecnum=27\p@ % subsubsection 88.8.8 plus 1.444pt
+\tocparanum=35\p@ % paragraph 88.8.8.8 plus 1.666pt
+\tocsubparanum=43\p@ % subparagraph 88.8.8.8.8 plus 1.888pt
+\def\calctocindent{%
+\tocsectotal=\tocchpnum
+\advance\tocsectotal by\tocsecnum
+\tocsubsectotal=\tocsectotal
+\advance\tocsubsectotal by\tocsubsecnum
+\tocsubsubsectotal=\tocsubsectotal
+\advance\tocsubsubsectotal by\tocsubsubsecnum
+\tocparatotal=\tocsubsubsectotal
+\advance\tocparatotal by\tocparanum}
+\calctocindent
+
+\def\l@section{\@dottedtocline{1}{\tocchpnum}{\tocsecnum}}
+\def\l@subsection{\@dottedtocline{2}{\tocsectotal}{\tocsubsecnum}}
+\def\l@subsubsection{\@dottedtocline{3}{\tocsubsectotal}{\tocsubsubsecnum}}
+\def\l@paragraph{\@dottedtocline{4}{\tocsubsubsectotal}{\tocparanum}}
+\def\l@subparagraph{\@dottedtocline{5}{\tocparatotal}{\tocsubparanum}}
+
+\def\listoffigures{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
+ \fi\section*{\listfigurename\@mkboth{{\listfigurename}}{{\listfigurename}}}
+ \@starttoc{lof}\if@restonecol\twocolumn\fi}
+\def\l@figure{\@dottedtocline{1}{0em}{1.5em}}
+
+\def\listoftables{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
+ \fi\section*{\listtablename\@mkboth{{\listtablename}}{{\listtablename}}}
+ \@starttoc{lot}\if@restonecol\twocolumn\fi}
+\let\l@table\l@figure
+
+\renewcommand\listoffigures{%
+ \section*{\listfigurename
+ \@mkboth{\listfigurename}{\listfigurename}}%
+ \@starttoc{lof}%
+ }
+
+\renewcommand\listoftables{%
+ \section*{\listtablename
+ \@mkboth{\listtablename}{\listtablename}}%
+ \@starttoc{lot}%
+ }
+
+\ifx\oribibl\undefined
+\ifx\citeauthoryear\undefined
+\renewenvironment{thebibliography}[1]
+ {\section*{\refname}
+ \def\@biblabel##1{##1.}
+ \small
+ \list{\@biblabel{\@arabic\c@enumiv}}%
+ {\settowidth\labelwidth{\@biblabel{#1}}%
+ \leftmargin\labelwidth
+ \advance\leftmargin\labelsep
+ \if@openbib
+ \advance\leftmargin\bibindent
+ \itemindent -\bibindent
+ \listparindent \itemindent
+ \parsep \z@
+ \fi
+ \usecounter{enumiv}%
+ \let\p@enumiv\@empty
+ \renewcommand\theenumiv{\@arabic\c@enumiv}}%
+ \if@openbib
+ \renewcommand\newblock{\par}%
+ \else
+ \renewcommand\newblock{\hskip .11em \@plus.33em \@minus.07em}%
+ \fi
+ \sloppy\clubpenalty4000\widowpenalty4000%
+ \sfcode`\.=\@m}
+ {\def\@noitemerr
+ {\@latex@warning{Empty `thebibliography' environment}}%
+ \endlist}
+\def\@lbibitem[#1]#2{\item[{[#1]}\hfill]\if@filesw
+ {\let\protect\noexpand\immediate
+ \write\@auxout{\string\bibcite{#2}{#1}}}\fi\ignorespaces}
+\newcount\@tempcntc
+\def\@citex[#1]#2{\if@filesw\immediate\write\@auxout{\string\citation{#2}}\fi
+ \@tempcnta\z@\@tempcntb\m@ne\def\@citea{}\@cite{\@for\@citeb:=#2\do
+ {\@ifundefined
+ {b@\@citeb}{\@citeo\@tempcntb\m@ne\@citea\def\@citea{,}{\bfseries
+ ?}\@warning
+ {Citation `\@citeb' on page \thepage \space undefined}}%
+ {\setbox\z@\hbox{\global\@tempcntc0\csname b@\@citeb\endcsname\relax}%
+ \ifnum\@tempcntc=\z@ \@citeo\@tempcntb\m@ne
+ \@citea\def\@citea{,}\hbox{\csname b@\@citeb\endcsname}%
+ \else
+ \advance\@tempcntb\@ne
+ \ifnum\@tempcntb=\@tempcntc
+ \else\advance\@tempcntb\m@ne\@citeo
+ \@tempcnta\@tempcntc\@tempcntb\@tempcntc\fi\fi}}\@citeo}{#1}}
+\def\@citeo{\ifnum\@tempcnta>\@tempcntb\else
+ \@citea\def\@citea{,\,\hskip\z@skip}%
+ \ifnum\@tempcnta=\@tempcntb\the\@tempcnta\else
+ {\advance\@tempcnta\@ne\ifnum\@tempcnta=\@tempcntb \else
+ \def\@citea{--}\fi
+ \advance\@tempcnta\m@ne\the\@tempcnta\@citea\the\@tempcntb}\fi\fi}
+\else
+\renewenvironment{thebibliography}[1]
+ {\section*{\refname}
+ \small
+ \list{}%
+ {\settowidth\labelwidth{}%
+ \leftmargin\parindent
+ \itemindent=-\parindent
+ \labelsep=\z@
+ \if@openbib
+ \advance\leftmargin\bibindent
+ \itemindent -\bibindent
+ \listparindent \itemindent
+ \parsep \z@
+ \fi
+ \usecounter{enumiv}%
+ \let\p@enumiv\@empty
+ \renewcommand\theenumiv{}}%
+ \if@openbib
+ \renewcommand\newblock{\par}%
+ \else
+ \renewcommand\newblock{\hskip .11em \@plus.33em \@minus.07em}%
+ \fi
+ \sloppy\clubpenalty4000\widowpenalty4000%
+ \sfcode`\.=\@m}
+ {\def\@noitemerr
+ {\@latex@warning{Empty `thebibliography' environment}}%
+ \endlist}
+ \def\@cite#1{#1}%
+ \def\@lbibitem[#1]#2{\item[]\if@filesw
+ {\def\protect##1{\string ##1\space}\immediate
+ \write\@auxout{\string\bibcite{#2}{#1}}}\fi\ignorespaces}
+ \fi
+\else
+\@cons\@openbib@code{\noexpand\small}
+\fi
+
+\def\idxquad{\hskip 10\p@}% space that divides entry from number
+
+\def\@idxitem{\par\hangindent 10\p@}
+
+\def\subitem{\par\setbox0=\hbox{--\enspace}% second order
+ \noindent\hangindent\wd0\box0}% index entry
+
+\def\subsubitem{\par\setbox0=\hbox{--\,--\enspace}% third
+ \noindent\hangindent\wd0\box0}% order index entry
+
+\def\indexspace{\par \vskip 10\p@ plus5\p@ minus3\p@\relax}
+
+\renewenvironment{theindex}
+ {\@mkboth{\indexname}{\indexname}%
+ \thispagestyle{empty}\parindent\z@
+ \parskip\z@ \@plus .3\p@\relax
+ \let\item\par
+ \def\,{\relax\ifmmode\mskip\thinmuskip
+ \else\hskip0.2em\ignorespaces\fi}%
+ \normalfont\small
+ \begin{multicols}{2}[\@makeschapterhead{\indexname}]%
+ }
+ {\end{multicols}}
+
+\renewcommand\footnoterule{%
+ \kern-3\p@
+ \hrule\@width 2truecm
+ \kern2.6\p@}
+ \newdimen\fnindent
+ \fnindent1em
+\long\def\@makefntext#1{%
+ \parindent \fnindent%
+ \leftskip \fnindent%
+ \noindent
+ \llap{\hb@xt@1em{\hss\@makefnmark\ }}\ignorespaces#1}
+
+\long\def\@makecaption#1#2{%
+ \vskip\abovecaptionskip
+ \sbox\@tempboxa{{\bfseries #1.} #2}%
+ \ifdim \wd\@tempboxa >\hsize
+ {\bfseries #1.} #2\par
+ \else
+ \global \@minipagefalse
+ \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
+ \fi
+ \vskip\belowcaptionskip}
+
+\def\fps@figure{htbp}
+\def\fnum@figure{\figurename\thinspace\thefigure}
+\def \@floatboxreset {%
+ \reset@font
+ \small
+ \@setnobreak
+ \@setminipage
+}
+\def\fps@table{htbp}
+\def\fnum@table{\tablename~\thetable}
+\renewenvironment{table}
+ {\setlength\abovecaptionskip{0\p@}%
+ \setlength\belowcaptionskip{10\p@}%
+ \@float{table}}
+ {\end@float}
+\renewenvironment{table*}
+ {\setlength\abovecaptionskip{0\p@}%
+ \setlength\belowcaptionskip{10\p@}%
+ \@dblfloat{table}}
+ {\end@dblfloat}
+
+\long\def\@caption#1[#2]#3{\par\addcontentsline{\csname
+ ext@#1\endcsname}{#1}{\protect\numberline{\csname
+ the#1\endcsname}{\ignorespaces #2}}\begingroup
+ \@parboxrestore
+ \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
+ \endgroup}
+
+% LaTeX does not provide a command to enter the authors institute
+% addresses. The \institute command is defined here.
+
+\newcounter{@inst}
+\newcounter{@auth}
+\newcounter{auco}
+\newdimen\instindent
+\newbox\authrun
+\newtoks\authorrunning
+\newtoks\tocauthor
+\newbox\titrun
+\newtoks\titlerunning
+\newtoks\toctitle
+
+\def\clearheadinfo{\gdef\@author{No Author Given}%
+ \gdef\@title{No Title Given}%
+ \gdef\@subtitle{}%
+ \gdef\@institute{No Institute Given}%
+ \gdef\@thanks{}%
+ \global\titlerunning={}\global\authorrunning={}%
+ \global\toctitle={}\global\tocauthor={}}
+
+\def\institute#1{\gdef\@institute{#1}}
+
+\def\institutename{\par
+ \begingroup
+ \parskip=\z@
+ \parindent=\z@
+ \setcounter{@inst}{1}%
+ \def\and{\par\stepcounter{@inst}%
+ \noindent$^{\the@inst}$\enspace\ignorespaces}%
+ \setbox0=\vbox{\def\thanks##1{}\@institute}%
+ \ifnum\c@@inst=1\relax
+ \gdef\fnnstart{0}%
+ \else
+ \xdef\fnnstart{\c@@inst}%
+ \setcounter{@inst}{1}%
+ \noindent$^{\the@inst}$\enspace
+ \fi
+ \ignorespaces
+ \@institute\par
+ \endgroup}
+
+\def\@fnsymbol#1{\ensuremath{\ifcase#1\or\star\or{\star\star}\or
+ {\star\star\star}\or \dagger\or \ddagger\or
+ \mathchar "278\or \mathchar "27B\or \|\or **\or \dagger\dagger
+ \or \ddagger\ddagger \else\@ctrerr\fi}}
+
+\def\inst#1{\unskip$^{#1}$}
+\def\fnmsep{\unskip$^,$}
+\def\email#1{{\tt#1}}
+\AtBeginDocument{\@ifundefined{url}{\def\url#1{#1}}{}%
+\@ifpackageloaded{babel}{%
+\@ifundefined{extrasenglish}{}{\addto\extrasenglish{\switcht@albion}}%
+\@ifundefined{extrasfrenchb}{}{\addto\extrasfrenchb{\switcht@francais}}%
+\@ifundefined{extrasgerman}{}{\addto\extrasgerman{\switcht@deutsch}}%
+}{\switcht@@therlang}%
+}
+\def\homedir{\~{ }}
+
+\def\subtitle#1{\gdef\@subtitle{#1}}
+\clearheadinfo
+
+\renewcommand\maketitle{\newpage
+ \refstepcounter{chapter}%
+ \stepcounter{section}%
+ \setcounter{section}{0}%
+ \setcounter{subsection}{0}%
+ \setcounter{figure}{0}
+ \setcounter{table}{0}
+ \setcounter{equation}{0}
+ \setcounter{footnote}{0}%
+ \begingroup
+ \parindent=\z@
+ \renewcommand\thefootnote{\@fnsymbol\c@footnote}%
+ \if@twocolumn
+ \ifnum \col@number=\@ne
+ \@maketitle
+ \else
+ \twocolumn[\@maketitle]%
+ \fi
+ \else
+ \newpage
+ \global\@topnum\z@ % Prevents figures from going at top of page.
+ \@maketitle
+ \fi
+ \thispagestyle{empty}\@thanks
+%
+ \def\\{\unskip\ \ignorespaces}\def\inst##1{\unskip{}}%
+ \def\thanks##1{\unskip{}}\def\fnmsep{\unskip}%
+ \instindent=\hsize
+ \advance\instindent by-\headlineindent
+ \if!\the\toctitle!\addcontentsline{toc}{title}{\@title}\else
+ \addcontentsline{toc}{title}{\the\toctitle}\fi
+ \if@runhead
+ \if!\the\titlerunning!\else
+ \edef\@title{\the\titlerunning}%
+ \fi
+ \global\setbox\titrun=\hbox{\small\rm\unboldmath\ignorespaces\@title}%
+ \ifdim\wd\titrun>\instindent
+ \typeout{Title too long for running head. Please supply}%
+ \typeout{a shorter form with \string\titlerunning\space prior to
+ \string\maketitle}%
+ \global\setbox\titrun=\hbox{\small\rm
+ Title Suppressed Due to Excessive Length}%
+ \fi
+ \xdef\@title{\copy\titrun}%
+ \fi
+%
+ \if!\the\tocauthor!\relax
+ {\def\and{\noexpand\protect\noexpand\and}%
+ \protected@xdef\toc@uthor{\@author}}%
+ \else
+ \def\\{\noexpand\protect\noexpand\newline}%
+ \protected@xdef\scratch{\the\tocauthor}%
+ \protected@xdef\toc@uthor{\scratch}%
+ \fi
+ \addcontentsline{toc}{author}{\toc@uthor}%
+ \if@runhead
+ \if!\the\authorrunning!
+ \value{@inst}=\value{@auth}%
+ \setcounter{@auth}{1}%
+ \else
+ \edef\@author{\the\authorrunning}%
+ \fi
+ \global\setbox\authrun=\hbox{\small\unboldmath\@author\unskip}%
+ \ifdim\wd\authrun>\instindent
+ \typeout{Names of authors too long for running head. Please supply}%
+ \typeout{a shorter form with \string\authorrunning\space prior to
+ \string\maketitle}%
+ \global\setbox\authrun=\hbox{\small\rm
+ Authors Suppressed Due to Excessive Length}%
+ \fi
+ \xdef\@author{\copy\authrun}%
+ \markboth{\@author}{\@title}%
+ \fi
+ \endgroup
+ \setcounter{footnote}{\fnnstart}%
+ \clearheadinfo}
+%
+\def\@maketitle{\newpage
+ \markboth{}{}%
+ \def\lastand{\ifnum\value{@inst}=2\relax
+ \unskip{} \andname\
+ \else
+ \unskip \lastandname\
+ \fi}%
+ \def\and{\stepcounter{@auth}\relax
+ \ifnum\value{@auth}=\value{@inst}%
+ \lastand
+ \else
+ \unskip,
+ \fi}%
+ \begin{center}%
+ \let\newline\\
+ {\Large \bfseries\boldmath
+ \pretolerance=10000
+ \@title \par}\vskip .8cm
+\if!\@subtitle!\else {\large \bfseries\boldmath
+ \vskip -.65cm
+ \pretolerance=10000
+ \@subtitle \par}\vskip .8cm\fi
+ \setbox0=\vbox{\setcounter{@auth}{1}\def\and{\stepcounter{@auth}}%
+ \def\thanks##1{}\@author}%
+ \global\value{@inst}=\value{@auth}%
+ \global\value{auco}=\value{@auth}%
+ \setcounter{@auth}{1}%
+{\lineskip .5em
+\noindent\ignorespaces
+\@author\vskip.35cm}
+ {\small\institutename}
+ \end{center}%
+ }
+
+% definition of the "\spnewtheorem" command.
+%
+% Usage:
+%
+% \spnewtheorem{env_nam}{caption}[within]{cap_font}{body_font}
+% or \spnewtheorem{env_nam}[numbered_like]{caption}{cap_font}{body_font}
+% or \spnewtheorem*{env_nam}{caption}{cap_font}{body_font}
+%
+% New is "cap_font" and "body_font". It stands for
+% fontdefinition of the caption and the text itself.
+%
+% "\spnewtheorem*" gives a theorem without number.
+%
+% A defined spnewthoerem environment is used as described
+% by Lamport.
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\def\@thmcountersep{}
+\def\@thmcounterend{.}
+
+\def\spnewtheorem{\@ifstar{\@sthm}{\@Sthm}}
+
+% definition of \spnewtheorem with number
+
+\def\@spnthm#1#2{%
+ \@ifnextchar[{\@spxnthm{#1}{#2}}{\@spynthm{#1}{#2}}}
+\def\@Sthm#1{\@ifnextchar[{\@spothm{#1}}{\@spnthm{#1}}}
+
+\def\@spxnthm#1#2[#3]#4#5{\expandafter\@ifdefinable\csname #1\endcsname
+ {\@definecounter{#1}\@addtoreset{#1}{#3}%
+ \expandafter\xdef\csname the#1\endcsname{\expandafter\noexpand
+ \csname the#3\endcsname \noexpand\@thmcountersep \@thmcounter{#1}}%
+ \expandafter\xdef\csname #1name\endcsname{#2}%
+ \global\@namedef{#1}{\@spthm{#1}{\csname #1name\endcsname}{#4}{#5}}%
+ \global\@namedef{end#1}{\@endtheorem}}}
+
+\def\@spynthm#1#2#3#4{\expandafter\@ifdefinable\csname #1\endcsname
+ {\@definecounter{#1}%
+ \expandafter\xdef\csname the#1\endcsname{\@thmcounter{#1}}%
+ \expandafter\xdef\csname #1name\endcsname{#2}%
+ \global\@namedef{#1}{\@spthm{#1}{\csname #1name\endcsname}{#3}{#4}}%
+ \global\@namedef{end#1}{\@endtheorem}}}
+
+\def\@spothm#1[#2]#3#4#5{%
+ \@ifundefined{c@#2}{\@latexerr{No theorem environment `#2' defined}\@eha}%
+ {\expandafter\@ifdefinable\csname #1\endcsname
+ {\global\@namedef{the#1}{\@nameuse{the#2}}%
+ \expandafter\xdef\csname #1name\endcsname{#3}%
+ \global\@namedef{#1}{\@spthm{#2}{\csname #1name\endcsname}{#4}{#5}}%
+ \global\@namedef{end#1}{\@endtheorem}}}}
+
+\def\@spthm#1#2#3#4{\topsep 7\p@ \@plus2\p@ \@minus4\p@
+\refstepcounter{#1}%
+\@ifnextchar[{\@spythm{#1}{#2}{#3}{#4}}{\@spxthm{#1}{#2}{#3}{#4}}}
+
+\def\@spxthm#1#2#3#4{\@spbegintheorem{#2}{\csname the#1\endcsname}{#3}{#4}%
+ \ignorespaces}
+
+\def\@spythm#1#2#3#4[#5]{\@spopargbegintheorem{#2}{\csname
+ the#1\endcsname}{#5}{#3}{#4}\ignorespaces}
+
+\def\@spbegintheorem#1#2#3#4{\trivlist
+ \item[\hskip\labelsep{#3#1\ #2\@thmcounterend}]#4}
+
+\def\@spopargbegintheorem#1#2#3#4#5{\trivlist
+ \item[\hskip\labelsep{#4#1\ #2}]{#4(#3)\@thmcounterend\ }#5}
+
+% definition of \spnewtheorem* without number
+
+\def\@sthm#1#2{\@Ynthm{#1}{#2}}
+
+\def\@Ynthm#1#2#3#4{\expandafter\@ifdefinable\csname #1\endcsname
+ {\global\@namedef{#1}{\@Thm{\csname #1name\endcsname}{#3}{#4}}%
+ \expandafter\xdef\csname #1name\endcsname{#2}%
+ \global\@namedef{end#1}{\@endtheorem}}}
+
+\def\@Thm#1#2#3{\topsep 7\p@ \@plus2\p@ \@minus4\p@
+\@ifnextchar[{\@Ythm{#1}{#2}{#3}}{\@Xthm{#1}{#2}{#3}}}
+
+\def\@Xthm#1#2#3{\@Begintheorem{#1}{#2}{#3}\ignorespaces}
+
+\def\@Ythm#1#2#3[#4]{\@Opargbegintheorem{#1}
+ {#4}{#2}{#3}\ignorespaces}
+
+\def\@Begintheorem#1#2#3{#3\trivlist
+ \item[\hskip\labelsep{#2#1\@thmcounterend}]}
+
+\def\@Opargbegintheorem#1#2#3#4{#4\trivlist
+ \item[\hskip\labelsep{#3#1}]{#3(#2)\@thmcounterend\ }}
+
+\if@envcntsect
+ \def\@thmcountersep{.}
+ \spnewtheorem{theorem}{Theorem}[section]{\bfseries}{\itshape}
+\else
+ \spnewtheorem{theorem}{Theorem}{\bfseries}{\itshape}
+ \if@envcntreset
+ \@addtoreset{theorem}{section}
+ \else
+ \@addtoreset{theorem}{chapter}
+ \fi
+\fi
+
+%definition of divers theorem environments
+\spnewtheorem*{claim}{Claim}{\itshape}{\rmfamily}
+\spnewtheorem*{proof}{Proof}{\itshape}{\rmfamily}
+\if@envcntsame % alle Umgebungen wie Theorem.
+ \def\spn@wtheorem#1#2#3#4{\@spothm{#1}[theorem]{#2}{#3}{#4}}
+\else % alle Umgebungen mit eigenem Zaehler
+ \if@envcntsect % mit section numeriert
+ \def\spn@wtheorem#1#2#3#4{\@spxnthm{#1}{#2}[section]{#3}{#4}}
+ \else % nicht mit section numeriert
+ \if@envcntreset
+ \def\spn@wtheorem#1#2#3#4{\@spynthm{#1}{#2}{#3}{#4}
+ \@addtoreset{#1}{section}}
+ \else
+ \def\spn@wtheorem#1#2#3#4{\@spynthm{#1}{#2}{#3}{#4}
+ \@addtoreset{#1}{chapter}}%
+ \fi
+ \fi
+\fi
+\spn@wtheorem{case}{Case}{\itshape}{\rmfamily}
+\spn@wtheorem{conjecture}{Conjecture}{\itshape}{\rmfamily}
+\spn@wtheorem{corollary}{Corollary}{\bfseries}{\itshape}
+\spn@wtheorem{definition}{Definition}{\bfseries}{\itshape}
+\spn@wtheorem{example}{Example}{\itshape}{\rmfamily}
+\spn@wtheorem{exercise}{Exercise}{\itshape}{\rmfamily}
+\spn@wtheorem{lemma}{Lemma}{\bfseries}{\itshape}
+\spn@wtheorem{note}{Note}{\itshape}{\rmfamily}
+\spn@wtheorem{problem}{Problem}{\itshape}{\rmfamily}
+\spn@wtheorem{property}{Property}{\itshape}{\rmfamily}
+\spn@wtheorem{proposition}{Proposition}{\bfseries}{\itshape}
+\spn@wtheorem{question}{Question}{\itshape}{\rmfamily}
+\spn@wtheorem{solution}{Solution}{\itshape}{\rmfamily}
+\spn@wtheorem{remark}{Remark}{\itshape}{\rmfamily}
+
+\def\@takefromreset#1#2{%
+ \def\@tempa{#1}%
+ \let\@tempd\@elt
+ \def\@elt##1{%
+ \def\@tempb{##1}%
+ \ifx\@tempa\@tempb\else
+ \@addtoreset{##1}{#2}%
+ \fi}%
+ \expandafter\expandafter\let\expandafter\@tempc\csname cl@#2\endcsname
+ \expandafter\def\csname cl@#2\endcsname{}%
+ \@tempc
+ \let\@elt\@tempd}
+
+\def\theopargself{\def\@spopargbegintheorem##1##2##3##4##5{\trivlist
+ \item[\hskip\labelsep{##4##1\ ##2}]{##4##3\@thmcounterend\ }##5}
+ \def\@Opargbegintheorem##1##2##3##4{##4\trivlist
+ \item[\hskip\labelsep{##3##1}]{##3##2\@thmcounterend\ }}
+ }
+
+\renewenvironment{abstract}{%
+ \list{}{\advance\topsep by0.35cm\relax\small
+ \leftmargin=1cm
+ \labelwidth=\z@
+ \listparindent=\z@
+ \itemindent\listparindent
+ \rightmargin\leftmargin}\item[\hskip\labelsep
+ \bfseries\abstractname]}
+ {\endlist}
+
+\newdimen\headlineindent % dimension for space between
+\headlineindent=1.166cm % number and text of headings.
+
+\def\ps@headings{\let\@mkboth\@gobbletwo
+ \let\@oddfoot\@empty\let\@evenfoot\@empty
+ \def\@evenhead{\normalfont\small\rlap{\thepage}\hspace{\headlineindent}%
+ \leftmark\hfil}
+ \def\@oddhead{\normalfont\small\hfil\rightmark\hspace{\headlineindent}%
+ \llap{\thepage}}
+ \def\chaptermark##1{}%
+ \def\sectionmark##1{}%
+ \def\subsectionmark##1{}}
+
+\def\ps@titlepage{\let\@mkboth\@gobbletwo
+ \let\@oddfoot\@empty\let\@evenfoot\@empty
+ \def\@evenhead{\normalfont\small\rlap{\thepage}\hspace{\headlineindent}%
+ \hfil}
+ \def\@oddhead{\normalfont\small\hfil\hspace{\headlineindent}%
+ \llap{\thepage}}
+ \def\chaptermark##1{}%
+ \def\sectionmark##1{}%
+ \def\subsectionmark##1{}}
+
+\if@runhead\ps@headings\else
+\ps@empty\fi
+
+\setlength\arraycolsep{1.4\p@}
+\setlength\tabcolsep{1.4\p@}
+
+\endinput
+%end of file llncs.cls
--- /dev/null
+\documentclass{llncs}
+
+\usepackage{mathql_macros}
+\newcommand\xcomment[1]{}
+
+\title{MathQL-1 Version 4\\Reference Documentation}
+\author{Ferruccio Guidi%
+\thanks{This work has been partially supported by
+MoWGLI (European FET Project IST-2001-33562).}
+}
+
+\institute{Department of Computer Science\\
+Mura Anteo Zamboni 7, 40127 Bologna, ITALY.\\
+\email{fguidi@cs.unibo.it}}
+
+\date{ }
+
+\begin{document}
+
+\maketitle
+
+\begin{abstract}
+\end{abstract}
+
+\addtocounter{tocdepth}{2}
+
+\section*{\contentsname}{
+\catcode`@=11
+\def\l@title#1#2{}
+\def\l@author#1#2{}
+\@starttoc{toc}
+\catcode`@=12}
+
+\input{mathql_overview}
+\input{mathql_introduction}
+\input{mathql_operational}
+\input{mathql_tests}
+\input{mathql_bib}
+
+\end{document}
--- /dev/null
+\begin{thebibliography}{99}
+
+\bibitem {APSCGS03}
+A. Asperti, L. Padovani, C. Sacerdoti Coen, F.Guidi, I. Schena:
+\emph{Mathematical Knowledge Management in HELM}.
+In Annals of Mathematics and Artificial Intelligence 38(1),
+Kluwer Academic Publishers (May 2003), pp. 27-46.
+
+\bibitem {Gui03}
+F. Guidi:
+\emph{Searching and Retrieving in Content-based Repositories of Formal
+Mathematical Knowledge}.
+Ph.D. Thesis in Computer Science, University of Bologna, March 2003. Technical
+report UBLCS 2003-06.
+
+\bibitem {GSC03}
+F. Guidi, C. Sacerdoti Coen:
+\emph{Querying Distributed Digital Libraries of Mathematics}.
+In Proc. of the 11th Symposium on the Integration of Symbolic Computation and
+Mechanized Reasoning (Calculemus 2003). Rome, Italy,
+September 2003. pages 17-30, Aracne. 2003.
+
+\bibitem {GS03}
+F. Guidi, I. Schena:
+\emph{A Query Language for a Metadata Framework about Mathematical Resources}.
+In Proc. of 2nd International Conference on Mathematical Knowledge
+Management (MKM 2003).
+Bertinoro, Italy, February 2003.
+LNCS 2594, pp. 105-118, Springer. 2003.
+
+\bibitem {Lan98}
+C. Laneve:
+\emph{La descrizione operazionale dei linguaggi di programmazione. \\
+Un'introduzione}
+FrancoAngeli, 1998.
+
+\bibitem {Lor02}
+D. Lordi:
+\emph{Sperimentazione e Sviluppo di Strumenti per la gestione di metadati}. \\
+Master Thesis in Computer Science, University of Bologna, 2002.
+
+\bibitem {RDF}
+\emph{Resource Description Framework (RDF) Model and Syntax Specification}.
+W3C Recommendation. February 22, 1999. \\
+\CURI{http://www.w3.org/TR/1999/REC-rdfsyntax-19990222/}.
+
+\bibitem {RDFS}
+\emph{RDF Vocabulary Description Language 1.0: RDF Schema}.
+W3C Working Draft. January 23, 2003
+\CURI{http://www.w3.org/TR/rdf-schema/}.
+
+\bibitem {Sam00}
+G. Sambin: \emph{Formal topology and domains}.
+Electronic Notes in Theoretical Computer Science, (35). 2000.
+
+\bibitem {Sch02}
+I. Schena:
+\emph{Towards a Semantic Web for Formal Mathematics}.
+Ph.D. dissertation. University of Bologna, 2002. Advisor: A. Asperti.
+
+\bibitem {Unicode}
+Unicode Consortium:
+\emph{The Unicode Standard, Version 3.2}. March 2002. \\
+\CURI{http://www.unicode.org/unicode/standard/standard.html}.
+
+\bibitem {URI}
+\emph{Uniform Resource Identifiers (URI): Generic Syntax (RFC 2396)}.
+August 1998. \\
+\CURI{http://www.ietf.org/rfc/rfc2396.txt}.
+
+\bibitem {W3Ca}
+\emph{Character Model for the World Wide Web 1.0},
+W3C Working Draft. April 30, 2002.
+\CURI{http://www.w3.org/TR/charmod/}.
+
+\bibitem {Win93}
+G. Winskel:
+\emph{The formal semantics of programming languages: an introduction}.
+MIT Press Series in the Foundations of Computing. London: MIT Press, 1993.
+
+\bibitem {XML}
+\emph{Extensible Markup Language (XML) 1.0 (Second Edition)}.
+W3C Recommendation. October 6, 2000. \CURI{http://www.w3.org/REC-xml}.
+
+\bibitem {XQuery}
+\emph{XQuery 1.0: An XML Query Language}.
+W3C Working Draft November 15, 2002. \CURI{http://www.w3.org/TR/xquery/}.
+
+\end{thebibliography}
--- /dev/null
+\section{Introduction}
+
+This paper presents {\MathQL} version 4 which is the latest version of the
+language, fully developed by the Author.
+For a description of the previous versions of {\MathQL} see: \cite{Gui03}
+(version 3), \cite{GS03} (version 2), \cite{Lor02} (version 1).
+The main novelties of this version are the elimination of some cast operators
+(producing a substantial simplification in the query structure and semantics),
+a clear distinction between the core language and the auxiliary functions of
+the basic library, a support for query generating functions, the possibility
+of extending the language adding new libraries of functions and a more uniform
+textual syntax.
+{\MathQL}.4 incorporates the features of {\MathQL}.3 not documented on paper%
+\footnote
+{See the ``what's new'' section of {\MathQL} Web Site:
+\CURI{helm.cs.unibo.it/mathql}.}
+and adds some new features improving {\MathQL} capabilities to post-process
+the query results.
+
+\input{mathql_introduction_avsets}
+\input{mathql_introduction_property}
+\input{mathql_introduction_core}
+\input{mathql_introduction_basic}
+\input{mathql_introduction_textual}
--- /dev/null
+\subsection {Sets of attributed values.} \label{AVSets}
+
+The data representation model used by {\MathQL} relies on the notion of
+\emph{set of attributed values} ({\av} set for short) that is, in practice,
+the only data type available in {\MathQL}.4. In this sense {\MathQL}.4 is a
+statically untyped language.%
+\footnote
+{A type system that fits {\MathQL} as an {\RDF}-oriented query language,
+should be driven from the {\RDFS} class system. This may be a future
+improvement.}
+Each {\av} in an {\av} set consists of a string%
+\footnote{When we say \emph{string}, we mean a finite sequence of characters.}
+(that we call the \emph{head string} or \emph{value}) and a (possibly empty)
+multiset of named attributes whose content is a set of strings.
+Attribute names are made of a (possibly empty) list of string components, so
+they can be hierarchically structured.
+Moreover the attributes of a value are partitioned into a set of \emph{groups}
+({\ie} subsets) to improve its structure.
+
+In the above description a \emph{set} is an \emph{unordered} finite
+sequence \emph{without} repetitions whereas a \emph{multiset} is an
+\emph{unordered} finite sequence \emph{with} repetitions.
+
+In the present context repetitions are defined as follows:
+two {\av}'s are repeated if they share the same head string without any
+condition on their attributes, two groups are repeated of they contain the
+same attributes (equal both in name and content), two attributes of a group
+are repeated if they share the same name without any condition on their
+content, and two strings are always compared in a case-sensitive manner.%
+\footnote
+{The Author's experience with {\MathQL} seems to show that the above
+definition of an {\av} set is just the right one among the many alternatives
+that were tried.}
+
+As we said, {\MathQL}.4 uses {\av} sets to represent many kinds of
+information:
+
+\begin{enumerate}
+
+\item
+A pool of {\RDF} triples having a common subject $r$, which in general is a
+{\URI} reference \cite{URI}%
+\footnote
+{A {\URI} \emph {reference} is a {\URI} with an optional fragment identifier.},
+is encoded in a single {\av} placing $r$ in the head string.
+The predicates of the triples are encoded as attribute names and their objects
+are placed in the attributes' contents.
+These contents are structured as multiple strings with the aim of holding the
+objects of repeated predicates.
+Moreover structured attribute names can encode various components of
+structured properties preserving their semantics.
+
+\begin{figure}
+\begin{footnotesize} \begin{verbatim}
+The RDF triples:
+ ("protocol", "dc:creator", "Sandro Hawke")
+ ("protocol", "dc:creator", "Eric Prud'hommeaux")
+ ("protocol", "dc:date", "2002-01-08")
+
+The corresponding attributed value:
+ "protocol" attr {/"dc:creator" = {"Sandro Hawke", "Eric Prud'hommeaux"};
+ /"dc:date" = "2002-01-08"}
+\end{verbatim} \end{footnotesize}
+\vspace{-1pc}
+\caption{The representation of a pool of {\RDF} triples} \label{AVOne}
+\end{figure}
+
+\figref{AVOne} shows how a set of triples can be coded in an {\av}.
+Note that the word \TT{attr} separates the head string from its attributes,
+braces enclose an attribute group in which attributes are separated by
+semicolons, and an equal sign separates an attribute name from its contents.
+
+In this setting the grouping feature can be used to separate semantically
+different classes of properties associated to a resource (as for instance
+Dublin Core metadata, Euler metadata and user-defined metadata).
+
+\item
+A pool of arbitrarily chosen {\RDF} triples is encoded in an {\av} set
+placing in each {\av} the subset of triples sharing the same head string.
+
+Note that the use of {\av} sets to build query results allows {\MathQL} queries
+to return sets of {\RDF} triples instead of mere sets of resources, in the
+spirit of what is currently done by other {\RDF}-oriented query languages.
+
+If the {\av}'s of an {\av} set share the same attribute names and grouping
+structure, this set can be represented as a table in which each row encodes
+an {\av} and each column is associated to an attribute (except the first one
+which holds the head strings).
+\figref{Table} shows an {\av} set describing the properties of two resources
+``A'' and ``B'' giving its table representation, in which the columns
+corresponding to attributes in the same group are clustered between
+double-line delimiters.%
+\footnote{A table with grouped labelled columns like the one above resembles a
+set of relational database tables.}
+
+\begin{figure}
+\begin{footnotesize} \begin{verbatim}
+"A" attr {/"major" = "1"; /"minor" = "2"},
+ {/"first" = "2002-01-01"; /"modified" = "2002-03-01"};
+"B" attr {/"major" = "1"; /"minor" = "7"},
+ {/"first" = "2002-02-01"; /"modified" = "2002-04-01"}
+\end{verbatim}
+\begin{center} \begin{tabular}{|c||c|c||c|c||}
+\hline & \textbf{``major''} & \textbf{``minor''} & \textbf{``first''} & \textbf{``modified''} \\
+\hline ``A'' & ``1'' & ``2'' & ``2002-01-01'' & ``2002-03-01'' \\
+\hline ``B'' & ``1'' & ``7'' & ``2002-02-01'' & ``2002-04-01'' \\
+\hline
+\end{tabular} \end{center} \end{footnotesize}
+\caption{A set of attributed values displayed as a table} \label{Table}
+\end{figure}
+
+The above example gives a spatial idea of the geometry of an {\av} set ({\ie}
+a query result) which fits in 4 dimensions: namely we can extend independently
+the set of the head strings (dimension 1), the attributes in each group
+(dimension 2), the groups in each {\av} (dimension 3) and the contents of each
+attribute (dimension 4).
+The metadata defined in the table of \figref{Table} will be used in subsequent
+examples.
+For this purpose assume that ``first'' and ``modified'' are the components
+of a structured property ``date'' available for the resources ``A'' and ``B''.
+
+\item
+The value of an {\RDF} property is encoded in an {\av} distinguishing three
+cases:
+
+\begin{itemize}
+
+\item
+If the property is unstructured, its value is placed in the {\av} head
+string and no attributes are defined.
+
+\item
+If the property is structured and its value has a main component%
+\footnote{Which is set by the \emph{rdf:value} property or defined by a
+specific application.},
+the content of this component is placed in the {\av} head string and the
+other components are stored in the {\av} attributes as in the case 1.
+
+\item
+For the value of a structured property without a main component, the head
+string is empty and the components are stored in the attributes.
+
+\end{itemize}
+
+\begin{figure}
+\begin{footnotesize} \begin{verbatim}
+First example, one instance:
+ "" attr {/"major" = "1"; /"minor" = "2"} no main component
+ "1" attr {/"minor" = "2"} main component is "major"
+ "2" attr {/"major" = "1"} main component is "minor"
+
+Second example: two separate instances:
+ "" attr {/"major" = "1"; /"minor" = "2"},
+ {/"major" = "1"; /"minor" = "7"} no main component
+ "1" attr {/"minor" = "2"}, {/"minor" = "7"} main component is "major"
+
+Third example: two mixed instances:
+ "" attr {/"major" = "3", "6"; /"minor" = {"4", "9"}} no main component
+\end{verbatim} \end{footnotesize}
+\vspace{-1pc}
+\caption{The representation of the structured value of a property}
+\label{AVTwo}
+\end{figure}
+
+\figref{AVTwo} (first example) shows three possible ways of representing in
+{\av}'s an instance of a structured property ``id'' whose value has two
+fields ({\ie} properties) ``major'' and ``minor''.
+In this instance, ``major'' is set to ``1'' and ``minor'' is set to ``2''.
+The representations depend on which component of ``id'' is chosen as the
+main component (none, ``major'' or ``minor'' respectively).
+Several structured property values sharing a common main component can be
+encodes in a single {\av} exploiting the grouping facility: in this case the
+attributes of every instance are enclosed in separate groups.
+\figref{AVTwo} (second example) shows the representations of two instances of
+``id'': the former and a new one for which ``major'' is ``1'' and ``minor'' is
+``7''.
+
+Note that if the attributes of the two groups are encoded in a single group,
+the notion of which components belong to the same property value can not be
+recovered in the general case because the values of an attribute form a set
+and thus are unordered.
+As an example think of two instances of ``id'' encoded as in \figref{AVTwo}
+(third example).
+
+\item
+A natural number is stored, using its decimal representation, in the head
+string of a single {\av} with no attributes.
+
+\item
+The boolean value \emph{false} is stored as an empty {\av} set, whereas
+an inhabited {\av} set may be interpreted as the boolean value \emph{true}.
+The default representation of \emph{true} is a single {\av} with an empty
+head string and no attributes.
+
+\end{enumerate}
+
+{\MathQL} defines five core binary operations on {\av} sets: two unions, two
+intersections and a difference. The first four are defined in terms of an
+operation, that we call \emph{addition}, involving two {\av}'s with the same
+head string.
+The result is an {\av} with the same head string of the operands but there are
+two ways to compose the attribute groups:
+
+\begin{itemize}
+
+\item
+with the \emph{set-theoretic} addition, the set of attribute groups in the
+resulting {\av} is the set-theoretic union of the sets of attribute groups in
+the operands;
+
+\item
+with the \emph{distributive} addition, the set of attribute groups in the
+resulting {\av} is the ``Cartesian product'' of the sets of attribute groups
+in the two operands.
+Here an element of the ``Cartesian product'' is not a pair of groups but it is
+the set-theoretic union of these groups where the contents of homonymous
+attributes are clustered together using set-theoretic unions.
+
+\end{itemize}
+
+\figref{Addition} shows an example of the two kinds of addition.
+
+\begin{figure}
+\begin{footnotesize} \begin{verbatim}
+Attributed values used as operands for the addition:
+ "1" attr {/"A" = "a"}, {/"B" = "b1"}
+ "1" attr {/"A" = "a"}, {/"B" = "b2"}
+
+Set-theoretic addition:
+" 1" attr {/"A" = "a"}, {/"B" = "b1"}, {/"B" = "b2"}
+
+Distributive addition:
+ "1" attr {/"A" = "a"}, {/"A" = "a"; /"B" = "b2"},
+ {/"B" = "b1"; /"A" = "a"}, {/"B" = {"b1", "b2"}}
+\end{verbatim} \end{footnotesize}
+\vspace{-1pc}
+\caption{The addition of attributed values}
+\label{Addition}
+\end{figure}
+
+Now we can discuss the five operations between {\av} sets:
+
+\begin{itemize}
+
+\item
+The two unions corresponds to the set-theoretic union of their operand where
+the {\av}'s sharing the head string are added either set-theoretically or
+distributively as explained above (thus we have a set-theoretic union and a
+distributive union in the two cases). In this context the empty {\av} set
+plays the role of the neutral element.
+These operations play a central role {\MathQL} architecture and allow to
+compose the attributes of the operands preserving their group structure.
+
+\item
+The two intersections are the dual of the above unions: they contain the
+{\av}'s whose head string appears in each argument where the {\av}'s sharing
+the head string are added either set-theoretically or distributively as before.
+
+The distributive intersection has the double benefit of filtering the
+common values of the given {\av} sets, and of merging their attribute groups
+in every possible way. This feature enables the possibility of performing
+additional filtering operations checking the content of the merged groups.
+
+\item
+The difference of two {\av} sets contains the {\av}'s of the first
+argument whose head string does not appear in the second argument.
+
+\end{itemize}
+
+\figref{Binary} shows how the above operations work in a simple example.
+
+\begin{figure}
+\begin{footnotesize} \begin{verbatim}
+Sets of attributed values used as operands for the operations:
+ "1" attr {/"A" = "a"}; "2" attr {/"B" = "b1"}
+ "2" attr {/"B" = "b2"}
+
+Set-theoretic union:
+ "1" attr {/"A" = "a"}; "2" attr {/"B" = "b1"}, {/"B" = "b2"}
+
+Distributive union:
+ "1" attr {/"A" = "a"}; "2" attr {/"B" = {"b1", "b2"}}
+
+Set-theoretic intersection:
+ "2" attr {/"B" = "b1"}, {/"B" = "b2"}
+
+Distributive intersection:
+ "2" attr {/"B" = {"b1", "b2"}}
+
+Difference:
+ "1" attr {/"A" = "a"}
+\end{verbatim} \end{footnotesize}
+\vspace{-1pc}
+\caption{The binary operations on sets of attributed values}
+\label{Binary}
+\end{figure}
--- /dev/null
+\subsection{The basic library} \label{Basic}
+
+The present paper leaves us too little space to present a complete
+description of {\MathQL}.4 basic library, so we only give a glance to the
+features it provides.
+
+For the user convenience {\MathQL}.4 includes a syntax extension for all the
+basic library functions, in order to hide the actual function invocation.
+
+Here are some of the provided constructions:
+
+\begin{itemize}
+
+\item
+\textbf{Aliases for commonly used constant {\av} sets.}
+\EM{empty}, \EM{false}, \EM{true}.
+
+\item
+\textbf{Conditional operator.}
+\TT{if} \EM{av-set} \TT{then} \EM{av-set} \TT{else} \EM{av-set}.
+Tests the first {\av} set for inhabitance and evaluates one of the other {\av}
+sets accordingly.
+
+\item
+\textbf{Standard \emph{select} clause.}
+\TT{select @}\EM{variable} \TT{from} \EM{av-set-1} \TT{where} \EM{av-set-2}.
+It is:
+\TT{for @}\EM{variable} \TT{in} \EM{av-set-1} \TT{sup}
+\TT{if} \EM{av-set-2} \TT{then @}\EM{variable} \TT{else empty}.
+
+\item
+\textbf{Set refinement}. The operator
+\TT{keep} \EM{optional-flag} \EM{name-list} \TT{in} \EM{av-set}
+removes from its argument every attribute whose name is included (or is not,
+according to the \EM{flag}) in the given \EM{name-list}.
+If the \EM{flag} is not present, the \EM{name-list} specifies the attributes
+to keep, whereas if the \EM{flag} is \TT{allbut}, the \EM{name-list} specifies
+the attributes to remove.
+Removing unwanted information from an {\av} set is useful in two cases: it
+lowers the complexity of intermediate query results increasing the performance
+of subsequent operations and it cleans the final query results making them
+easier to manage for the application that submits the query.%
+\footnote
+{Interpreting {\av} sets as relational database tables, this functionality
+allows to select the columns a table is made of, as with the {\SQL}
+\emph{select} operator.}
+
+\item
+\textbf{projections.}
+The operator
+\TT{proj} \EM{name} \TT{of} \EM{av-set} makes the set-theoretic union of the
+contents that the specified attribute has in each group of the given {\av} set.
+Each element of this union then becomes the head string of an {\av} without
+attributes and the set of these is returned.%
+\footnote
+{This is the content of a labelled column of the given \EM{av-set} viewed as a
+table.}
+See \figref{Proj}.
+
+\begin{figure}
+\begin{footnotesize} \begin{verbatim}
+proj /"name" of ["1" attr {\"name" = {"a", "b"}}, {\"name" = {"b", "c"}}
+gives "a"; "b"; "b"
+\end{verbatim} \end{footnotesize}
+\vspace{-1pc}
+\caption{A simple projection} \label{Proj}
+\end{figure}
+
+The construction \TT{keep} \EM{av-set} is also provided to remove all the
+attributes in the given \EM{av-set} ({\ie} the list of the attributes to keep
+is empty).%
+\footnote
+{This is the content of the first column of the \EM{av-set} viewed as a table.}
+
+\item
+\textbf{Core operations on {\av} sets.}
+\EM{av-set} \EM{core-operator} \EM{av-set}
+returns an {\av} set composing the two operands according to the specified
+\EM{core-operator} (see \subsecref{AVSets}) which can be \TT{union}
+(set-theoretic union), \TT{intersect} (set-theoretic intersection) or
+\TT{diff} (difference).
+\TT{union} and \TT{intersect} are also provided in their $n$-ary form
+($ n \ge 1 $ for \TT{intersect}) and the $n$-ary union has the syntax
+extension:
+\verb+{+ \EM{av-set} \TT{,} $\cdots$ \TT{,} \EM{av-set} \verb+}+.
+
+\item
+\textbf{Logical operations on {\av} sets.}
+\EM{and}, \EM{or}, \EM{xor}, \EM{not}.
+They are inspired by the C-style Boolean operators defined for the
+integer numbers. In particular:
+
+\TT{not} \EM{av-set}:
+returns \emph{false} if the \EM{av-set} is inhabited, or \emph{true} otherwise.
+
+\EM{av-set-1} \TT{and} \EM{av-set-2}:
+gives \EM{av-set-2} if \EM{av-set-1} is inhabited, or \emph{false} otherwise.
+
+\EM{av-set-1} \TT{or} \EM{av-set-2}:
+returns \EM{av-set-1} if it is inhabited, or \EM{av-set-2} otherwise.
+
+\EM{av-set-1} \TT{xor} \EM{av-set-2}:
+gives \emph{false} if both av-sets are inhabited or empty, or the inhabited
+\EM{av-set} otherwise.
+
+\TT{and} and \TT{or} are also available in their $n$-ary form.
+
+\item
+\textbf{Comparisons between {\av} sets.}
+\EM{av-set} \EM{test-operator} \EM{av-set}.
+Following the repetition rules of {\av} sets presented in \subsecref{AVSets},
+these operators work just on the head strings of their arguments and
+discard the attributes. All of them return \emph{false} or \emph{true}
+according to the outcome of the respective test.
+The \emph{test-operator} includes: \TT{sub} (set-theoretic subset relation),
+\TT{eq} (set-theoretic quality), \TT{meet} (inhabitance of the set-theoretic
+intersection), \TT{le} (numeric less-or-equal-than), \TT{lt} (numeric
+less-than).%
+\footnote{\TT{le} and \TT{lt} return \emph{false} if their operands are invalid
+numbers.}
+
+Note that the set-theoretic ``meet'' operator
+({\ie} $ V \meet W \equiv (\lex v \in V)\ v \in W $)
+is the natural companion of the corresponding ``sub'' operator
+({\ie} $ V \sub W \equiv (\lall v \in V)\ v \in W $) being its logical dual
+and is already being used successfully in the context of a constructive
+({\ie} intuitionistic and predicative) approach to point-free topology
+(see \cite{Sam00} for details).
+
+\item
+\textbf{Cardinality of an {\av} set.}
+This information is retrieved by the operator \TT{count} \EM{av-set} that
+returns an {\av} set representing a natural number.
+
+\end{itemize}
+
--- /dev/null
+\subsection{The core language}
+
+{\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
+query results. The components of this infrastructure are listed below:
+
+\begin{itemize}
+
+\item
+\textbf{Explicit sets of attributed values.}
+An explicit {\av} set can be placed in a query in two forms:
+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 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}
+
+\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.
+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" = $var}]+.
+
+The scope of {\MathQL} variables is typical for an imperative programming
+language and any case of assignment propagation will be indicated.
+
+\item
+\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
+\textbf{Unbounded iteration.}
+This construction comes in two forms:
+
+\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 evaluated in
+a common context during the iteration ({\ie} the variables defined in both
+are available to both) and this context is also propagated outside the
+\TT{while}.
+
+\item
+\textbf{Bounded iteration.}
+Also this construction comes in two forms:
+
+\TT{for @}\EM{variable} \TT{in} \EM{av-set} \TT{sup} \EM{av-set}:
+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}:
+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.
+The element variables are kept distinct from the set variables (therefore
+\TT{\$variable} and \TT{@variable} may appear in the same query without
+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
+\textbf{Addition of groups.}
+\TT{add} \EM{optional-flag} \EM{attribute-groups} \TT{in} \EM{av-set}
+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
+\TT{distr} flag the addition is distributive.
+The \EM{attribute-groups} can be given explicitly (in the same syntax used for
+explicit {\av} sets) or they can be replaced by an element variable. In the
+latter case the attribute groups of the {\av} stored in the variable are
+considered.
+
+\figref{Add} shows how to build a one-element {\av} set using \TT{add}.
+
+\begin{figure}
+\begin{footnotesize} \begin{verbatim}
+The set of attributed values given explicitly:
+ ["head" attr {/"attribute" = property /"metadata" of "resource"}]
+
+The same set built with the add operator:
+ add {/"attribute" = property /"metadata" of "resource"} in "head"
+\end{verbatim} \end{footnotesize}
+\vspace{-1pc}
+\caption{A simple use of the add operator}
+\label{Add}
+\end{figure}
+
+\item
+\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:
+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 these groups (recall that different groups are allowed to
+contain attributes with the same name). If one evaluation gives a non empty
+result, the default representation of \emph{true} is returned, in the other
+case the empty {\av} set, {\ie} \emph{false}, is returned.
+
+\item
+\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
+{\MathQL} code representing an {\av} set ({\ie} they interface a {\MathQL}
+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+}+
+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+}+
+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 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{Basic}) that integrate the core language providing several
+facilities.
+
+\end{itemize}
--- /dev/null
+\subsection{High level access to metadata} \label{HighAccess}
+
+{\MathQL} high level access to an {\RDF} database is \emph{graph-oriented} and
+is delegated to its \TT{property} operator that builds a \emph{result} {\av}
+set starting from two mandatory arguments: the \emph{source} {\av} set and the
+\emph{head path}.
+Other optional arguments may be used to change its default behaviour or to
+request advanced functionalities.
+
+This operator has the following syntax, where a path has the structure of an
+attribute name ({\ie} a list of strings) and denotes a (possibly empty) finite
+sequence of contiguous arcs (describing properties in the {\RDF} graph%
+\footnote
+{When we say \emph{{\RDF} graph}, we actually mean both the {\RDFM} graph and
+the {\RDFS} graph.}%
+).
+
+\begin{center}
+\TT{property} \EM{optional-flags} \EM{head-path} \EM{optional-clauses} \TT{of}
+\EM{optional-flag} \EM{av-set}
+\end{center}
+
+\begin{figure}
+\begin{footnotesize} \begin{verbatim}
+ These examples refer to the resources "A" and "B" of Figure 2.
+
+Example 1: reading an unstructured property - simple case:
+ property /"id"/"major" of {"A", "B"} gives "1"
+ property /"id"/"minor" of {"A", "B"} gives "2"; "7"
+
+Example 2: reading an unstructured property - use of pattern:
+ property /"id"/"minor" of pattern ".*" gives "2"; "7"
+
+Example 3: reading a structured property without main component:
+ property /"id" attr /"major", /"minor" of {"A", "B"}
+ generates the following attributed values:
+ "" attr {/"major" = "1"; /"minor" = "2"};
+ "" attr {/"major" = "1"; /"minor" = "7"}
+ that are composed with the set-theoretic union giving:
+ "" attr {/"major" = "1"; /"minor" = "2"},
+ {/"major" = "1"; /"minor" = "7"}
+
+Example 4: reading a structured property specifying a main component:
+ property /"id" main /"major" attr /"minor" of {"A", "B"} gives
+ "1" attr {/"minor" = "2"}, {/"minor" = "7"}
+
+Example 5: the renaming mechanism:
+ property /"id" attr /"minor" as /"new-name" of {"A", "B"} gives
+ "" attr {/"new-name" = "2"}, {/"new-name" = "7"}
+
+Example 6: imposing constraints on property values:
+ property /"date" istrue /"first" in "2002-01-01"
+ attr /"modified" of {"A", "B"} and
+ property /"date" istrue /"first" match ".*01.*"
+ attr /"modified" of {"A", "B"} give
+ "" attr {/"modified" = "2002-03-01"}
+ Only the instance of "date" with "first" set to "2002-01-01"
+ is considered.
+
+Example 7: inverse traversal of the head path:
+property inverse /"date" attr /"first" in "" gives
+"A" attr {/"first" = "2002-01-01"}; "B" attr {/"first" = "2002-02-01"}
+
+Example 8: some triples of an access relation:
+The triples formalizing the property "date" of the resource "A":
+("A", /"date", "");
+("A", /"date"/"first", "2002-01-01");
+("A", /"date"/"modified", "2002-03-01")
+\end{verbatim} \end{footnotesize}
+\vspace{-1pc}
+\caption{The ``property'' operator}
+\label{Property}
+\end{figure}
+
+In the simplest case \TT{property} is used to read the values of a (possibly
+compound) property with an unstructured value and does the following:
+
+\begin{enumerate}
+
+\item
+It computes the instances of the given path in the {\RDF} graph available to
+the query engine, using the resources specified in the head strings of the
+source {\av} set (call them source resources) as start-nodes.
+
+\item
+The computation gives a set of nodes ({\ie} the end-nodes of the instantiated
+paths) which are the values of the instances of the (possibly compound)
+property specified by the path and concerning the source resources.
+
+\item
+These values, encoded into {\av}'s as explained above, are composed by means
+of the {\MathQL} set-theoretic union to form the result {\av} set.
+
+\end{enumerate}
+
+\figref{Property} (example 1) shows an instance of this procedure.
+Note that the result sets of this example have no attributes and that a path
+is represented by a slash-separated list of strings denoting the path's arcs.%
+\footnote{If needed, the empty path is represented by a single slash.}
+
+Using the \TT{pattern} flag, \TT{property} can be instructed to regard the
+values of the source {\av} set as POSIX regular expressions rather than as
+constant strings.
+In this case \TT{pattern} selects the set of resources matching at least one
+of the given expressions.
+See for instance \figref{Property} (example 2).
+
+If we want to read the value of a structured property we can specify the
+value's main component in the \TT{main} \EM{optional-clause} (this
+specification overrides the default setting inferred from the {\RDF} graph
+through the \emph{rdf:value} property) and the list of the value's secondary
+components in the \TT{attr} \EM{optional-clause}.
+
+Note that if a secondary component is not listed in the \TT{attr} clause, it
+will not be read.
+Also recall that, when the result {\av}'s are formed, the main component is
+is read in the head string, whereas the secondary components are
+encoded using the attributes of a single group.
+See for instance \figref{Property} (examples 3 and 4).
+As a component of a property's value may be a structured property, its
+specification (appearing in the \TT{main} or \TT{attr} clause) is
+actually a path in the {\RDF} graph starting from the end-node of the head
+path.
+
+Note that the name of an attribute, which by default is its defining path in
+the \TT{attr} clause, can be changed with an optional \TT{as} clause for the
+user's convenience. See for instance \figref{Property} (example 5).
+Note that the assigned name must be a path for typing reasons.
+The alternative could be to use a simple string but in any case a string can
+be seen as a one-element path.
+
+In the default case \TT{property} builds its result considering every
+component of the {\RDFM} graph ({\ie} every {\RDFM}) but we can constrain
+some nodes of the inspected components to have (or not to have) a given value,
+with the aim of improving the performance of the inspection procedure.
+The constrained nodes are specified in the \TT{istrue} and \TT{istrue}
+\EM{optional-clauses} and the constraining values are expressed by \TT{in} or
+\TT{match} constructions depending on their semantics (constant values or
+POSIX regular expressions respectively).
+See for instance \figref{Property} (example 6).
+Again a constrained node may be the value of a compound property, therefore
+its specification (appearing in the \TT{istrue} or \TT{isfalse} clause) is
+a path in the {\RDF} graph starting from the end-node of the head path.
+
+\TT{property} allows to access the {\RDFS} property hierarchy by specifying
+a flag \TT{sub} or \TT{super}.
+If the \TT{sub} flag is present, \TT{property} inspects the instances of the
+default tree (made by the head path and by the \EM{optional-clauses} paths)
+and every other tree obtained by substituting an arc $ p $ with the arc of a
+subproperty of $ p $.
+If the \TT{super} flag is present, super-property arcs are substituted instead.
+
+\TT{property} also allows the inverse traversal of its head path if the
+\TT{inverse} flag is specified.
+In this case the operator works as follows:
+
+\begin{enumerate}
+
+\item
+It instantiates the head path using as end-nodes the values whose main
+component is specified in head strings of the source {\av} set.
+
+\item
+It encodes the resources corresponding to the instances of the start-nodes into
+{\av}'s assigning the attributes obtained instantiating the attribute paths%
+\footnote{The paths in the \EM{optional-clauses} are never traversed backward.}
+and builds the result set composing these {\av}'s with the set-theoretic union.
+
+\end{enumerate}
+
+See for instance \figref{Property} (example 7).
+
+Formally \TT{property} accesses the {\RDF} graph through an \emph{access
+relation} which is a set of triples $ (r_1, p, r_2) $ where $ r_1 $ and
+$ r_2 $ are strings, and $ p $ is a path.
+Each triple is a sort of ``extended {\RDF} triple'' in the sense that $ r_1 $
+is a resource for which some metadata is provided, $ p $ is a path in the
+{\RDF} graph and $ r_2 $ is the main value of the end-node of the instance of
+$ p $ starting from $ r_1 $ (this includes the instances of sub- and
+super-arcs of $ p $ if necessary).
+See for instance \figref{Property} (example 8).
+{\MathQL} does not provide for any built-in access relation so any query
+engine can freely define the access relations that are appropriate with
+respect to the metadata it can access.
+
+It is worth remarking, as it was already stressed in \cite{Gui03,GS03}, that
+the concept of access relation corresponds to the abstract concept of property
+in the basic {\RDF} data model which draws on well established principles from
+various data representation communities.
+In this sense an {\RDF} property can be thought of either as an attribute of a
+resource (traditional attribute-value pairs model), or as a relation between
+a resource and a value (entity-relationship model).
+This observation leads us to conclude that {\MathQL} is sound and complete
+with respect to querying an abstract {\RDF} metadata model.
+Finally note that access relations are close to {\RDF} entity-relationship
+model, but they do not work if we allow paths with an arbitrary number of
+loops ({\ie} with an arbitrary length) because this would lead to creating
+infinite sets of triples.
+If we want to handle this case, we need to turn these relations into
+multivalued functions.
--- /dev/null
+\subsection{Textual syntax} \label{Textual}
+
+In this section we present {\MathQL}.4 textual syntax using the same notation
+that we adopted in \cite{GS03,Gui03}. In particular the grammatical
+productions we use resemble {\BNF} with some {\POSIX} formalism:
+
+\begin{itemize}
+
+\item
+\TT{::=} defines a grammatical production by means of a regular expression.
+
+Regular expressions are made of the following elements
+(\TT{...} is a placeholder):
+
+\item
+\TT{`...`} represents any character in a character set;
+
+\item
+\verb+`^ ...`+ represents any character (U+20 to U+7E) not in a character set;
+
+\item
+\TT{"..."} represents a string to be matched verbatim;
+
+\item
+\GP{...} represents a regular expression defined by a grammatical production;
+
+\item
+\TT{... ...} represents a conjunctive regular expression;
+
+\item
+\TT{... | ...} represents a disjunctive regular expression;
+
+\item
+\TT{[ ... ]?} represents an optional regular expression;
+
+\item
+\TT{[ ... ]+} represents a regular expression to be repeated one or more times;
+
+\item
+\TT{[ ... ]*} represents a regular expression to be repeated zero or more times;
+
+\item
+\TT{[ ... ]} represents a grouped regular expression.
+
+\end{itemize}
+
+\begin{figure}
+\begin{footnotesize} \begin{verbatim}
+<dec> ::= '0 - 9'
+<num> ::= <dec> [ <dec> ]*
+<hex> ::= <dec> | 'A - F' | 'a - f'
+<escaped> ::= "u" <hex> <hex> <hex> <hex> | '"' | "\" | "^"
+<string> ::= '"' [ "\" <escaped> "^" | '^ "\^' ]* '"'
+<path> ::= "/" | [ "/" <string> ]+
+\end{verbatim} \end{footnotesize}
+\vskip-1pc
+\caption{Textual syntax of numbers, strings and paths} \label{StrTS}
+\end{figure}
+
+\begin{figure}
+\begin{footnotesize}
+\begin{center} \begin{tabular}{|l|l|c|}
+\hline {\bf Escape sequence} & {\bf Unicode character} & {\bf Text} \\
+\hline \verb+\u....^+ & U+.... & \\
+\hline \verb+\"^+ & U+0022 & \verb+"+ \\
+\hline \verb+\\^+ & U+005C & \verb+\+ \\
+\hline \verb+\^^+ & U+005E & \verb+^+ \\
+\hline
+\end{tabular} \end{center}
+\end{footnotesize}
+\vskip-1pc
+\caption{Textual syntax of escaped characters} \label{EscTS}
+\end{figure}
+
+Queries and results can contain quoted constant strings with the syntax of
+\figref {StrTS}%
+\footnote
+{Note that the first slash of the \GP{path} is not optional as in {\MathQL}.3.}
+and the meaning of the escaped sequences is shown in \figref{EscTS} (where
+$ .... $ is a 4-digit placeholder).
+{\MathQL} character escaping syntax aims at complying with W3C character model
+for the World Wide Web \cite{W3Ca} which recommends a support for standard
+Unicode characters (U+0000 to U+FFFF) and escape sequences with start/end
+delimiters.
+In particular {\MathQL} escape delimiters (backslash and caret) are chosen
+among the \emph{unwise} characters for {\URI} references (see \cite{URI})
+because {\URI} references are the natural content of constant strings and
+these characters should not be so frequent in them.
+
+\begin{figure}
+\begin{footnotesize} \begin{verbatim}
+<alpha> ::= [ 'A - Z' | 'a - z' | `_` ]+
+<id> ::= <alpha> [ <alpha> | <dec> ]*
+<svar> ::= "$" <id>
+<evar> ::= "@" <id>
+\end{verbatim}\end{footnotesize} %$
+\vskip-1pc
+\caption{Textual syntax of variables} \label{VarTS}
+\end{figure}
+
+Queries can also contain \emph{set} variables (production \GP{svar}) and
+\emph{element} variables (production \GP{evar}) according to the syntax of
+\figref{VarTS}.%
+\footnote{This syntax resembles the one of programming languages identifiers.}
+A set variable holds an {\av} set, {\ie} a query result, while an element
+variable holds an {\av}.
+
+\begin{figure}
+\begin{footnotesize} \begin{verbatim}
+<ref> ::= [ "sub" | "super" ]?
+<qualifier> ::= [ "inverse" ]? <ref> <path>
+<main> ::= [ "main" <path> ]?
+<cons> ::= <path> [ "in" | "match" ] <query>
+<istrue> ::= [ "istrue" <cons> [ "," <cons> ]* ]?
+<isfalses> ::= [ "isfalse" <cons> [ "," <cons> ]* ]*
+<exp> ::= <path> [ "as" <path> ]?
+<sec> ::= [ "attr" <exp> [ "," <exp> ]* ]?
+<opt_args> ::= <main> <istrue> <isfalses> <sec>
+<source> ::= [ "pattern" ]? <query>
+<paths> ::= <path> [ "," <path> ]*
+<query> ::= "(" <query> ")" | <string> | "[" <xavs> "]"
+ | "property" <qualifier> <opt_args> "of" <source>
+ | "let" <svar> "=" <query> "in" <query>
+ | <query> ";;" <query> | <svar> | <evar>
+ | "ex" <query> | <evar> "." <path>
+ | "add" [ "distr" ]? [ <xgroups> | <evar> ] "in" <query>
+ | "for" <evar> "in" <query> [ "sup" | "inf" ] <query>
+ | "while" <query> [ "sup" | "inf" ] <query>
+ | <path> "{" [ <paths> ]? "}" "{" <queries> "}"
+ | "gen" <path> [ "{" <queries> "}" | "in" <query> ]
+<queries> ::= [ <query> [ "," <query> ]* ]?
+<xattr> ::= <path> "=" <query>
+<xgroup> ::= "{" <xattr> [ ";" <xattr> ]* "}"
+<xgroups> ::= <xgroup> [ "," <xgroup> ]*
+<xav> ::= <string> [ "attr" <xgroups> ]?
+<xavs> ::= [ <xav> [ ";" <xav> ]* ]?
+\end{verbatim} \end{footnotesize}
+\vskip-1pc
+\caption{Textual syntax of queries} \label{QueryTS}
+\end{figure}
+
+\begin{figure}
+\begin{footnotesize} \begin{verbatim}
+<attr> ::= <path> "=" <string> | "{" <string> [ "," <string> ]* "}"
+<group> ::= "{" <attr> [ ";" <attr> ]* "}"
+<av> ::= <string> [ "attr" <group> [ "," <group> ]* ]?
+<avs> ::= [ <av> [ ";" <av> ]* ]?
+\end{verbatim} \end{footnotesize}
+\vskip-1pc
+\caption{Textual syntax of results} \label{ResultTS}
+\end{figure}
+
+\begin{figure}
+\begin{footnotesize} \begin{verbatim}
+<query> ::= "empty" | "false" | "true"
+ | [ "not" | "count" | "proj" <path> "of" ] <query>
+ | <query> [ "and" | "or" | "xor" ] <query>
+ | <query> [ "sub" | "meet" | "eq" | "le" | "lt" ] <query>
+ | <query> [ "union" | "intersect" | "diff" ] <query>
+ | "{" <queries> "}"
+ | "keep" [ "allbut" ]? [ <paths> "in" ]? <query>
+ | "if" <query> "then" <query> "else" <query>
+ | "select" <evar> "from" <query> "where" <query>
+\end{verbatim} \end{footnotesize}
+\vskip-1pc
+\caption{Textual syntax of the basic extension} \label{BasicTS}
+\end{figure}
+
+The core infrastructure of {\MathQL}.4 defines a syntax for queries
+(\figref{QueryTS}, production \GP{query}) and a syntax for results
+(\figref{ResultTS}, production \GP{avs}).
+A syntax extension for the most common functions of the basic library is
+also provided for the user's convenience and for backward compatibility with
+{\MathQL}.3. The syntax extension concerning the functions covered in this
+paper is shown in \figref{BasicTS}.
+Note that this extension makes \GP{avs} an instance of \GP{xavs}.
+
+
--- /dev/null
+\usepackage{amssymb}
+
+\newcommand\CURI[1]{\texttt{<#1>}}
+\newcommand\EM[1]{\noindent\hbox{\frenchspacing\em #1}}
+\newcommand\TT[1]{\noindent\hbox{\frenchspacing\tt #1}}
+\newcommand\RM[1]{\noindent\hbox{\frenchspacing\rm #1}}
+\newcommand\secref[1]{Section~\ref{#1}}
+\newcommand\subsecref[1]{Subsection~\ref{#1}}
+\newcommand\figref[1]{Figure~\ref{#1}}
+\newcommand\ie{{\frenchspacing i.e.}}
+\newcommand\oft{\mathrel :}
+\newcommand\lex{\exists}
+\newcommand\lall{\forall}
+\newcommand\sub{\subseteq}
+\newcommand\meet{\between}
+\newcommand\sand{\cap}
+\newcommand\sdor{\sqcup}
+\newcommand\sor{\cup}
+\newcommand\bigsor{\bigcup}
+\newcommand\app{\mathbin @}
+\newcommand\fa{\phi}
+\newcommand\fb{\psi}
+\newcommand\st{\mathrel |}
+\newcommand\p{{^\prime}}
+\newcommand\jolly{\mathbin\square}
+\newcommand\gdlap[2]{\vbox to 0pt {\vskip#2\hbox{#1}\vss}}
+\newcommand\setnames@[2]{&\gdlap{\kern2pt$#1$}{#2}}
+\newcommand\imain[1]{{\offinterlineskip\lineskip=2pt\noindent
+ $\vcenter{\halign{\hss$##$\hss&##\hss\cr#1\crcr}}$}}
+\newcommand\iname[1]{\cr\hrulefill\setnames@{#1}{-1.0ex}\cr}
+\newcommand\irule[3]{\imain{#1 \iname{#2} #3}}
+\newcommand\spc{\hspace{1em}}
+\newcommand\icr{\cr}
+\newcommand\Nop{\noindent\hbox to 0pt{\vbox to 1ex{\vfil}\hfil}}
+
+\newcommand\BNF{\textsc{bnf}}
+\newcommand\CAML{\textsc{caml}}
+\newcommand\Galax{\textsc{galax}}
+\newcommand\HELM{\textsc{helm}}
+\newcommand\MathQL{\textsc{mathql-1}}
+\newcommand\MySQL{\textsc{mysql}}
+\newcommand\POSIX{\textsc{posix}}
+\newcommand\PostgreSQL{\textsc{postgresql}}
+\newcommand\RDF{\textsc{rdf}}
+\newcommand\RDFM{\textsc{rdf model}}
+\newcommand\RDFS{\textsc{rdf schema}}
+\newcommand\SQL{\textsc{sql}}
+\newcommand\URI{\textsc{uri}}
+\newcommand\XML{\textsc{xml}}
+\newcommand\XQuery{\textsc{xquery}}
+
+\newcommand\av{{\frenchspacing a.v.}}
+
+\newcommand\D{\Delta}
+\newcommand\G{\Gamma}
+\newcommand\ES{\emptyset}
+\newcommand\bigsum{\bigoplus}
+\newcommand\daq{\mathrel{\Downarrow_q}}
+\newcommand\dar{\mathrel{\Downarrow_r}}
+\newcommand\distr{\mathbin\odot}
+\newcommand\dprod{\mathbin\boxtimes}
+\newcommand\dsum{\mathbin\boxplus}
+\newcommand\g{(\G_s, \G_e, \G_g)}
+\newcommand\get[2]{#1(#2)}
+\newcommand\sdiff{\mathbin\ominus}
+\newcommand\set[3]{#1[#2 \gets #3]}
+\newcommand\sprod{\mathbin\otimes}
+\newcommand\ssum{\mathbin\oplus}
+
+\newcommand\Boole{\TT{Boole}}
+\newcommand\Listof{\TT{ListOf}}
+\newcommand\Setof{\TT{SetOf}}
+\newcommand\Str{\TT{Str}}
+\newcommand\Num{\TT{Num}}
+
+\newcommand\All{\TT{All}}
+\newcommand\Exp{\TT{Exp}}
+\newcommand\F{\TT{F}}
+\newcommand\For{\TT{For}}
+\newcommand\Fst{\TT{Fst}}
+\newcommand\Fsts{\TT{Fsts}}
+\newcommand\Fun{\TT{Fun}}
+\newcommand\Gen{\TT{Gen}}
+\newcommand\Head{\TT{Head}}
+\newcommand\Istrue{\TT{IsT}}
+\newcommand\Keep{\TT{Keep}}
+\newcommand\Match{\TT{Match}}
+\newcommand\Name{\TT{Name}}
+\newcommand\Pattern{\TT{Pattern}}
+\newcommand\Proj{\TT{Proj}}
+\newcommand\Property{\TT{Property}}
+\newcommand\Snd{\TT{Snd}}
+\newcommand\Src{\TT{Src}}
+\newcommand\Unquote{\TT{Unq}}
+\newcommand\T{\TT{T}}
+
+\newcommand\GP[1]{\TT{<#1>}}
+
+\newcommand\Set{\textsf{Set}}
+\newcommand\Prop{\textsf{Prop}}
+\newcommand\MainConclusion{\textsf{MainConclusion}}
+\newcommand\MainHypothesis{\textsf{MainHypothesis}}
+\newcommand\occurrence{\textsf{occurrence}}
+\newcommand\refObj{\textsf{refObj}}
--- /dev/null
+\section {Operational Semantics} \label {Operational}
+
+This section describes {\MathQL} semantics, that we present in a natural
+operational style \cite{Lan98,Win93}.
+Here we use a simple type system that includes basic types such as strings and
+Booleans, and some type constructors such as product and exponentiation.
+$ y \oft Y $ will denote a typing judgement.
+This semantics is not meant as a formal system \emph{per se}, but should be a
+reference for implementors.
+
+\input{mathql_operational_background}
+\input{mathql_operational_core}
+\input{mathql_operational_basic}
+
--- /dev/null
+\subsection {Mathematical background}
+
+As background for the semantics, we revise the one presented in
+\cite{Gui03,GS03}.
+
+{\Str} denotes the type of strings and its elements are the finite sequences
+of Unicode \cite{Unicode} characters.
+Grammatical productions denote the subtype of {\Str} containing the produced
+sequences of characters.
+
+{\Num} denotes the type of numbers and is the subtype of {\Str} defined by
+\GP{num}. In this type, numbers are represented by their decimal expansion.
+
+$ \Setof\ Y $ denotes the type of finite sets ({\ie} unordered finite
+sequences without repetitions) over $ Y $ and
+$ \Listof\ Y $ denotes the type of lists ({\ie} ordered finite sequences)
+over $ Y $.
+We will use the notation $ [y_1, \cdots, y_m] $ for the list whose elements
+are $ y_1, \cdots, y_m $ ($ \{y_1, \cdots, y_m\} $ will denote a set as
+usual).
+
+{\Boole}, the type of Boolean values, is defined as the set
+$ \{\ES, \{("", \ES)\}\} $ of type $ \Setof\ \Setof\ (\Str \times \Setof\ Y) $
+where the first element stands for \emph{false} (denoted by {\F}) and the
+second element stands for \emph{true} (denoted by {\T}).%
+\footnote{This definition allows to treat a Boolean value as an {\av} set.}
+
+$ Y \times Z $ denotes the product of the types $ Y $ and $ Z $ whose elements
+are the ordered pairs $ (y, z) $ such that $ y \oft Y $ and $ z \oft Z $.
+The notation is also extended to a ternary product.
+$ Y \to Z $ denotes the type of functions from $ Y $ to $ Z $ and $ f\ y $
+denotes the application of $ f \oft Y \to Z $ to $ y \oft Y $.
+Relations over types, such as equality, are seen as functions to {\Boole}.
+
+With the above constructors we can give a formal meaning to most of the
+standard notation. For instance we will use the following:
+
+\begin{itemize}
+
+\item
+$ {\ES} \oft (\Setof\ Y) $
+
+\item
+$ {\lex} \oft ((\Setof\ Y) \to \Boole) \to \Boole $
+
+\item
+$ {\lall} \oft ((\Setof\ Y) \to \Boole) \to \Boole $
+
+\item
+$ {\in} \oft Y \to (\Setof\ Y) \to \Boole $ (infix)
+
+\item
+$ {\sub} \oft (\Setof\ Y) \to (\Setof\ Y) \to \Boole $ (infix)
+
+\item
+$ {\meet} \oft (\Setof\ Y) \to (\Setof\ Y) \to \Boole $ (infix)
+
+\item
+$ {\sand} \oft (\Setof\ Y) \to (\Setof\ Y) \to (\Setof\ Y) $ (infix)
+
+\item
+$ {\sor} \oft (\Setof\ Y) \to (\Setof\ Y) \to (\Setof\ Y) $ (infix)
+
+\item
+$ {\sdor} \oft (\Setof\ Y) \to (\Setof\ Y) \to (\Setof\ Y) $
+(the disjoint union, infix)
+
+\item
+$ \le \oft \Num \to \Num \to \Boole $ (infix)
+
+\item
+$ < \oft \Num \to \Num \to \Boole $ (infix)
+
+\item
+$ \# \oft (\Setof\ Y) \to \Num $ (the size operator)
+
+\item
+$ \app \oft (\Listof\ Y) \to (\Listof\ Y) \to (\Listof\ Y) $
+(the concatenation, infix)
+
+\item
+$ \lnot \oft \Boole \to \Boole $
+
+\end{itemize}
+
+\noindent
+Note that $ \lall $ and $ \lex $ are always decidable because the sets are
+finite by definition.
+
+\noindent
+$ U \meet W $ means $ (\lex u \in U)\ u \in W $ and expresses the fact that
+$ U \sand W $ is inhabited as a primitive notion, {\ie} without mentioning
+intersection and equality as for $ U \sand W \neq \ES $, which is equivalent
+but may be implemented less efficiently in real cases%
+\footnote{As for the Boolean condition $ \fa \lor \fb $ which may have a more
+efficient implementation than $ \lnot(\lnot \fa \land \lnot \fb) $.}.
+$ U \meet W $ is a natural companion of $ U \sub W $ being its logical dual
+(recall that $ U \sub W $ means $ (\lall u \in U)\ u \in W $)
+and is already being used successfully in the context of a constructive
+({\ie} intuitionistic and predicative) approach to point-free topology
+\cite{Sam00}.
+
+Sets of couples play a central role in our presentation and we will use:
+
+\begin{itemize}
+
+\item
+$ \Fst \oft (Y \times Z) \to Y $ such that $ \Fst\ (y, z) = y $.
+
+\item
+$ \Snd \oft (Y \times Z) \to Z $ such that $ \Snd\ (y, z) = z $.
+
+\item
+$ \Fsts \oft \Setof\ (Y \times Z) \to \Setof\ Z $ such that
+$ \Fsts\ U = \{\Fst\ u \st u \in U\} $.
+
+\item
+With the same notation, if $ W $ contains just one couple whose first
+component is $ y $, then $ \get{W}{y} $ is the second component of that couple.
+In the other cases $ \get{W}{y} $ is not defined.
+This operator has type $ (\Setof\ (Y \times Z)) \to Y \to Z $.
+
+\item
+Moreover $ \set{W}{y}{z} $ is the set obtained from $ W $ removing every
+couple whose first component is $ y $ and adding the couple $ (y, z) $.
+The type of this operator is
+$ (\Setof\ (Y \times Z)) \to Y \to Z \to (\Setof\ (Y \times Z)) $.
+
+\item
+Also $ U + W $ is the union of two sets of couples in the following sense:
+
+\begin{footnotesize}
+\begin{center} \begin{tabular}{rll}
+%
+$ U + \ES $ & rewrites to & $ U $ \\
+$ U + (W \sdor \{(y, z)\}) $ & rewrites to & $ \set{U}{y}{z} + W $
+%
+\end{tabular} \end{center}
+\end{footnotesize}
+
+\end{itemize}
+
+The last three operators are used to read, write and join association sets,
+which are sets of couples such that the first components of two different
+elements are always different.
+These sets will be exploited to formalize the memories appearing in evaluation
+contexts.
--- /dev/null
+\subsection {The basic library}
+
+In this section we present the functions provided by the {\MathQL}.4 basic
+library. Describing the whole library would require an amount of space that
+goes beyond the limits of this paper so we include here just a selection of
+the available functions (the ones for which we gave the syntax extension in
+\secref{Textual}).
+
+The function below are grouped by their arity.
+
+\begin{itemize}
+
+\item
+\textbf{The predefined {\av} sets.}
+The functions \TT{/"empty"}, \TT{/"false"} and \newline \TT{/"true"} take no
+path arguments and no set arguments.
+
+\begin{footnotesize}
+\begin{center}
+%
+\irule{\Nop}{}{\Fun\ \TT{/"empty"}\ [\,]\ [\,]\ \G \equiv \F} \spc
+\irule{\Nop}{}{\Fun\ \TT{/"false"}\ [\,]\ [\,]\ \G \equiv \F}
+\end{center}
+\begin{center}
+%
+\irule{\Nop}{}{\Fun\ \TT{/"true"}\ [\,]\ [\,]\ \G \equiv \T}
+%
+\end{center}
+\end{footnotesize}
+
+Moreover ``\TT{empty}'' rewrites to ``\verb+fun /"empty" {} {}+'',
+``\TT{false}'' rewrites to ``\verb+fun /"false" {} {}+'' and
+``\TT{true}'' rewrites to ``\verb+fun /"true" {} {}+''.
+
+\item
+\textbf{Boolean negation and size.}
+The functions \TT{/"not"} and \TT{/"count"} take no path arguments and one set
+argument.
+Here Rule 1 overrides rule 2.
+
+\begin{footnotesize}
+\begin{center}
+%
+\irule{(\G, x) \daq \F}{1}{\Fun\ \TT{/"not"}\ [\,]\ [x]\ \G \equiv \T} \spc
+\irule{(\G, x) \daq S}{2}{\Fun\ \TT{/"not"}\ [\,]\ [x]\ \G \equiv \F}
+\end{center}
+\begin{center}
+%
+\irule{(\G, x) \daq S}{}{\Fun\ \TT{/"count"}\ [\,]\ [x]\ \G \equiv \#\ S}
+%
+\end{center}
+\end{footnotesize}
+
+Moreover ``\TT{not} x'' rewrites to ``\verb+fun /"not" {} {+x\verb+}+''
+and ``\TT{count} x'' rewrites to ``\verb+fun /"count" {} {+x\verb+}+''.
+
+\item
+\textbf{Boolean xor, set-theoretic and numerical tests, difference.}
+\TT{/"xor"}, \TT{/"sub"}, \TT{/"meet"}, \TT{/"eq"}, \TT{/"le"}, \TT{/"lt"} and
+\TT{/"diff"} take no path arguments and two set arguments.
+The rule with the lowest number is applied first.
+
+\begin{footnotesize}
+\begin{center}
+%
+\irule{(\G, x_1) \daq \F \spc (\G, x_2) \daq \F}{1}
+ {\Fun\ \TT{/"xor"}\ [\,]\ [x_1, x_2]\ \G \equiv \T} \spc
+\irule{(\G, x_1) \daq S_1 \spc (\G, x_2) \daq \F}{2}
+ {\Fun\ \TT{/"xor"}\ [\,]\ [x_1, x_2]\ \G \equiv S_1}
+%
+\end{center}
+\begin{center}
+%
+\irule{(\G, x_1) \daq \F \spc (\G, x_2) \daq S_2}{3}
+ {\Fun\ \TT{/"xor"}\ [\,]\ [x_1, x_2]\ \G \equiv S_2} \spc
+\irule{(\G, x_1) \daq S_1 \spc (\G, x_2) \daq S_2}{4}
+ {\Fun\ \TT{/"xor"}\ [\,]\ [x_1, x_2]\ \G \equiv \F}
+%
+\end{center}
+\begin{center}
+%
+\irule{(\G, x_1) \daq S_1 \spc (\G, x_2) \daq S_2}{}
+ {\Fun\ \TT{/"sub"}\ [\,]\ [x_1, x_2]\ \G \equiv (\Fsts\ S_1 \sub \Fsts\ S_2)}
+%
+\end{center}
+\begin{center}
+%
+\irule{(\G, x_1) \daq S_1 \spc (\G, x_2) \daq S_2}{}
+ {\Fun\ \TT{/"meet"}\ [\,]\ [x_1, x_2]\ \G \equiv (\Fsts\ S_1 \meet \Fsts\ S_2)}
+%
+\end{center}
+\begin{center}
+%
+\irule{(\G, x_1) \daq S_1 \spc (\G, x_2) \daq S_2}{}
+ {\Fun\ \TT{/"eq"}\ [\,]\ [x_1, x_2]\ \G \equiv (\Fsts\ S_1 = \Fsts\ S_2)}
+%
+\end{center}
+\begin{center}
+%
+\irule{(\G, x_1) \daq \{(r_1, A_1)\} \spc (\G, x_2) \daq \{(r_2, A_2)\}}{}
+ {\Fun\ \TT{/"le"}\ [\,]\ [x_1, x_2]\ \G \equiv (r_1 \le r_2)}
+%
+\end{center}
+\begin{center}
+%
+\irule{(\G, x_1) \daq \{(r_1, A_1)\} \spc (\G, x_2) \daq \{(r_2, A_2)\}}{}
+ {\Fun\ \TT{/"lt"}\ [\,]\ [x_1, x_2]\ \G \equiv (r_1 < r_2)}
+%
+\end{center}
+\begin{center}
+%
+\irule{(\G, x_1) \daq S_1 \spc (\G, x_2) \daq S_2}{}
+ {\Fun\ \TT{/"eq"}\ [\,]\ [x_1, x_2]\ \G \equiv (S_1 \sdiff S_2)}
+%
+\end{center}
+\end{footnotesize}
+
+where $\sdiff$ is a helper function two rewrite rules:
+
+\begin{footnotesize}
+\begin{center} \begin{tabular}{lrll}
+5 &
+$ (S_1 \sdor \{(r, A_1)\}) \sdiff (S_2 \sdor \{(r, A_2)\}) $ & rewrites to &
+$ S_1 \sdiff S_2 $ \\
+6 & $ S_1 \sdiff S_2 $ & rewrites to & $ S_1 $
+%
+\end{tabular} \end{center}
+\end{footnotesize}
+
+``x \TT{xor} y'' rewrites to ``\verb+fun /"xor" {} {+x\TT{,}y\verb+}+'',
+``x \TT{sub} y'' rewrites to \newline ``\verb+fun /"sub" {} {+x\TT{,}y\verb+}+'',
+``x \TT{meet} y'' rewrites to ``\verb+fun /"meet" {} {+x\TT{,}y\verb+}+'',
+``x \TT{eq} y'' rewrites to ``\verb+fun /"eq" {} {+x\TT{,}y\verb+}+'',
+``x \TT{le} y'' rewrites to \newline ``\verb+fun /"le" {} {+x\TT{,}y\verb+}+'',
+``x \TT{lt} y'' rewrites to ``\verb+fun /"lt" {} {+x\TT{,}y\verb+}+'' and
+``x \TT{diff} y'' rewrites to ``\verb+fun /"diff" {} {+x\TT{,}y\verb+}+''
+
+\item
+\textbf{Conditional operator and standard \emph{select} clause}.
+\TT{/"if"} takes no path arguments and three set arguments.
+The usual rule overriding policy applies.
+
+\begin{footnotesize}
+\begin{center}
+%
+\irule{(\G, x_1) \daq \F \spc (\G, x_3) \daq S_3}{1}
+ {\Fun\ \TT{/"if"}\ [\,]\ [x_1, x_2, x_2]\ \G \equiv S_3} \spc
+\irule{(\G, x_1) \daq S_1 \spc (\G, x_2) \daq S_2}{2}
+ {\Fun\ \TT{/"if"}\ [\,]\ [x_1, x_2, x_2]\ \G \equiv S_2}
+%
+\end{center}
+\end{footnotesize}
+
+``\TT{if} x \TT{then} y \TT{else} z'' rewrites to
+``\verb+fun /"if" {} {+x\TT{,}y\TT{,}z\verb+}+'' and
+``\TT{select} i \TT{from} x \TT{where} y'' rewrites to
+``\TT{for} i \TT{in} x \TT{sup} \TT{if} y \TT{then} i \TT{else} \TT{empty}''.
+
+\item
+\textbf{Intersection without attribute distribution.}
+\TT{/"intersect"} takes no path arguments and any positive number of set
+arguments.
+
+\begin{footnotesize}
+\begin{center}
+%
+\irule{(\G, x_1) \daq S_1 \spc \cdots \spc (\G, x_m) \daq S_m}{}
+ {\Fun\ \TT{/"intersect"}\ [\,]\ [x_1, \cdots, x_m]\ \G \equiv
+ (S_1 \sprod \cdots \sprod S_m)}
+%
+\end{center}
+\end{footnotesize}
+
+As usual
+``x \TT{intersect} y'' rewrites to ``\verb+fun /"intersect" {} {+x\TT{,}y\verb+}+''.
+
+\item
+\textbf{Union without attribute distribution, Boolean conjunction and
+disjunction.}
+\TT{/"union"}, \TT{/"and"} and \TT{/"or"} take no path arguments and any
+number of set arguments.
+The usual rule overriding policy applies.
+
+\begin{footnotesize}
+\begin{center}
+%
+\irule{\Nop}{}{\Fun\ \TT{/"union"}\ [\,]\ [\,]\ \G \equiv \F} \spc
+\irule{(\G, x_1) \daq S_1 \spc \cdots \spc (\G, x_m) \daq S_m}{}
+ {\Fun\ \TT{/"union"}\ [\,]\ [x_1, \cdots, x_m]\ \G \equiv
+ (S_1 \ssum \cdots \ssum S_m)}
+%
+\end{center}
+\begin{center}
+%
+\irule{\Nop}{}{\Fun\ \TT{/"and"}\ [\,]\ [\,]\ \G \equiv \T} \spc
+\irule{\Nop}{}{\Fun\ \TT{/"or"}\ [\,]\ [\,]\ \G \equiv \F}
+%
+\end{center}
+\begin{center}
+%
+\irule{\Fun\ \TT{/"and"}\ [\,]\ l\ \G \equiv \F}{1}
+ {\Fun\ \TT{/"and"}\ [\,]\ (l \app [x])\ \G \equiv \F} \spc
+\irule{\Fun\ \TT{/"or"}\ [\,]\ l\ \G \equiv \F \spc (\G, x) \daq S}{3}
+ {\Fun\ \TT{/"or"}\ [\,]\ (l \app [x])\ \G \equiv S}
+%
+\end{center}
+\begin{center}
+%
+\irule{\Fun\ \TT{/"and"}\ [\,]\ l\ \G \equiv S_l \spc (\G, x) \daq S}{2}
+ {\Fun\ \TT{/"and"}\ [\,]\ (l \app [x])\ \G \equiv S} \spc
+\irule{\Fun\ \TT{/"or"}\ [\,]\ l\ \G \equiv S_l}{4}
+ {\Fun\ \TT{/"or"}\ [\,]\ (l \app [x])\ \G \equiv S_l}
+\end{center}
+\end{footnotesize}
+
+``x \TT{and} y'' rewrites to ``\verb+fun /"and" {} {+x\TT{,}y\verb+}+'',
+``x \TT{or} y'' rewrites to \newline ``\verb+fun /"or" {} {+x\TT{,}y\verb+}+'',
+``x \TT{union} y'' rewrites to \kern-1.1pt ``\verb+fun /"union" {} {+x\TT{,}y\verb+}+''
+and ``\verb+{+x$_1$\TT{,}$\cdots$\TT{,}x$_m$\verb+}+'' rewrites to
+``\verb+fun /"union" {} {+x$_1$\TT{,}$\cdots$\TT{,}x$_m$\verb+}+''.
+
+\item
+\textbf{Projection.}
+\TT{/"proj"} takes one path argument and one set argument.
+
+\begin{footnotesize}
+\begin{center}
+%
+\irule {p \oft \TT{<path>} \spc
+ (\G, x) \daq \{ (r_1, A_1), \cdots, (r_m, A_m) \}}{}
+ {\Fun\ \TT{/"proj"}\ [p]\ [x]\ \G \equiv
+ \Head\ (\Proj\ (\Name\ p)\ A_1 \sor \cdots \sor \Proj\ (\Name\ p)\ A_m)}
+%
+\end{center}
+\begin{center} \begin{tabular}{rll}
+%
+$ \Proj\ p\ \{G_1, \cdots, G_n\} $ & rewrites to &
+$ \get{G_1}{p} \sor \cdots \sor \get{G_n}{p} $ \\
+$ \Head\ \{s_1, \cdots, s_k\} $ & rewrites to & $ \{ (s_1, \ES), \cdots, (s_k, \ES) \} $
+\end{tabular} \end{center}
+\end{footnotesize}
+
+where, for each $ 1 \le j \le n $, $ \get{G_j}{p} $ is $ \ES $ if $ p $ is not
+defined in $ G_j $.
+
+Moreover
+``\TT{proj} p \TT{of} x'' rewrites to ``\verb+fun /"proj" {+p\verb+} {+x\verb+}+''.
+
+\item
+\textbf{Refinement.}
+The functions \TT{/"keep"/"these"} and \TT{/"keep"/"allbut"} take any number
+of path arguments and one set argument.
+In the following rules if $ l $ is $ [p_1, \cdots, p_m] $ then
+$ W $ is $ \{\Name\ p_1, \cdots, \Name\ p_m\} $ Moreover {\Keep} and $\Keep\p$
+are helper functions and the usual rule overriding policy applies.
+
+\begin{footnotesize}
+\begin{center}
+%
+\irule{l \oft \Listof\ \TT{<path>} \spc (\G, x) \daq S}{}
+ {\Fun\ \TT{/"keep"/"these"}\ l\ [x]\ \G \equiv
+ \{ (r, \bigsor \{ \Keep\ \T\ W\ G \st G \in A \}) \st (r, A) \in S \}}
+%
+\end{center}
+\begin{center}
+%
+\irule{l \oft \Listof\ \TT{<path>} \spc (\G, x) \daq S}{}
+ {\Fun\ \TT{/"keep"/"allbut"}\ l\ [x]\ \G \equiv
+ \{ (r, \bigsor \{ \Keep\ \F\ W\ G \st G \in A \}) \st (r, A) \in S \}}
+%
+\end{center}
+\begin{center}
+%
+\irule{\Keep\p\ b\ W\ G\ \RM{rewrites to}\ \ES}{1}
+{\Keep\ b\ W\ G\ \RM{rewrites to}\ \ES} \spc
+\irule{\Keep\p\ b\ W\ G\ \RM{rewrites to}\ G\p}{2}
+{\Keep\ b\ W\ G\ \RM{rewrites to}\ \{G\p\}}
+%
+\end{center}
+\begin{center} \begin{tabular}{rll}
+%
+$ \Keep\p\ \T\ W\ G $ & rewrites to & $ \{ (p, V) \in G \st p \in W \} $ \\
+$ \Keep\p\ \F\ W\ G $ & rewrites to & $ \{ (p, V) \in G \st p \notin W \} $
+%
+\end{tabular} \end{center}
+\end{footnotesize}
+
+``\TT{keep} p$_1$\TT{,}$\cdots$\TT{,}p$_m$ \TT{in} x'' rewrites to
+``\TT{fun /"keep"/"these"} \verb+{+p$_1$\TT{,}$\cdots$\TT{,}p$_m$\verb+}+ \verb+{+x\verb+}+'',
+``\TT{keep} x'' rewrites to ``\TT{fun /"keep"/"these"} \verb+{}+ \verb+{+x\verb+}+'',
+``\TT{keep allbut} p$_1$\TT{,}$\cdots$\TT{,}p$_m$ \TT{in} x'' rewrites to
+``\TT{fun /"keep"/"allbut"} \verb+{+p$_1$\TT{,}$\cdots$\TT{,}p$_m$\verb+}+ \verb+{+x\verb+}+''
+and
+``\TT{keep allbut} x'' rewrites to ``\TT{fun /"keep"/"allbut"} \verb+{}+ \verb+{+x\verb+}+''.
+
+Note that ``\TT{keep allbut} x'' gives the same result as ``x'' does.
+
+\end{itemize}
--- /dev/null
+\subsection {The core language} \label{OCore}
+
+\subsubsection*{Preliminaries}
+
+With the above background we are able to type the main objects needed in the
+formalization:
+
+\begin{itemize}
+
+\item
+A path $ p $ is a list of strings therefore its type is
+$ T_{0a} = \Listof\ \Str $.
+
+\item
+The attribute contents $ V $ are an object of type $ T_{0b} = \Setof\ \Str $.
+
+\item
+An attribute group $ G $ is an association set connecting the attribute names
+to their contents, therefore its type is
+$ T_1 = \Setof\ (T_{0a} \times T_{0b}) $.
+
+\item
+A head string $ r $ is an object of type $ \Str $.
+
+\item
+A set $ A $ of attribute groups is an object of type $ T_2 = \Setof\ T_1 $.
+
+\item
+An {\av}, {\ie} a head string with its attribute groups, has type
+$ T_3 = \Str \times T_2 $.
+
+\item
+A set $ S $ of {\av}'s is an association set of type $ T_4 = \Setof\ T_3 $.
+
+\item
+A triple of an attributed relation is of type
+$ T_5 = \Str \times \Str \times (T_{0a} \to \Str) $.
+
+\end{itemize}
+
+When a constant string appearing in a {\MathQL} expression is unquoted, the
+surrounding double quotes are deleted and each escaped sequence is translated
+according to \figref{EscTS}.
+This operation is formally performed by the function
+$ \Unquote $ of type $ \Str \to \Str $.
+Moreover $ \Name \oft \GP{path} \to T_{0a} $ is a helper function that
+converts a linearized path in its structured representation.
+Formally $ \Name\ (\TT{/}q_1\TT{/} \cdots \TT{/}q_m) $
+rewrites to $ [\Unquote\ q_1, \cdots, \Unquote\ q_m] $.
+
+The semantics of {\MathQL} expressions denoting queries is given by the infix
+relation $ \daq $ that evaluates a query to an {\av} set.
+These expressions are evaluated in a context $ \G = \g $
+which is a triple of association sets that connect
+set variables to {\av} sets, element variables to {\av}'s and element
+variables to attribute groups.
+Therefore the type $ K $ of the context $ \G $ is:
+
+\begin{footnotesize} \begin{center}
+$
+\Setof\ (\GP{svar} \times T_4) \times
+\Setof\ (\GP{evar} \times T_3) \times % $ \\ $ \times\
+\Setof\ (\GP{evar} \times T_1)
+$
+\end{center} \end{footnotesize}
+
+\noindent
+and the evaluating relation is of the following type:
+
+\begin{footnotesize}
+\begin{center} \begin{tabular}{l}
+$ \mathord{\daq} \oft (K \times \GP{query}) \times (K \times T_4) \to \Boole $.
+\end{tabular} \end{center}
+\end{footnotesize}
+
+The context components $ \G_s $ and $ \G_e $ are used to store the contents of
+variables, while $ \G_g $ is used by the \TT{ex} operator to be presented
+below.
+
+In the following we will write $ (\G, x) \daq S $ to abbreviate
+$ (\G, x) \daq (\G, S) $.
+
+The semantics of {\MathQL} expressions denoting results is given by the infix
+relation $ \dar \oft \GP{avs} \times T_4 \to \Boole $ that evaluates a result
+to an {\av} set.
+
+\subsubsection*{Queries}
+
+The first group of \GP{query} expressions include the representation of
+explicit {\av} sets and the syntactic grouping facility:
+
+\begin{itemize}
+
+\item
+The syntactic grouping is obtained enclosing a \GP{query} between \TT{(}
+and \TT{)}.
+An explicit {\av} set can be represented either by a single string, which is
+converted into a single {\av} with no attributes, or by a \GP{xavs}
+(extended {\av} set) expression enclosed between \TT{[} and \TT{]}.
+Such an expression describes all the components of an {\av} set and is
+evaluated using the rules given below.
+
+\begin{footnotesize}
+\begin{center}
+%
+\irule{(\G, x) \daq S}{}{(\G, (x)) \daq S} \spc
+\irule{q \oft \GP{string}}{}{(\G, q) \daq \{(\Unquote\ q, \ES)\}}
+%
+\end{center}
+\begin{center}
+%
+\irule{x_1, \cdots, x_m \in \GP{xav} \spc
+ (\G, \TT{[} x_1 \TT{]}) \daq S_1 \spc \cdots \spc (\G, \TT{[} x_m \TT{]}) \daq S_m}{}
+ {(\G, \TT{[} x_1 \TT{;} \cdots \TT{;} x_m \TT{]}) \daq S_1 \ssum \cdots \ssum S_m}
+%
+\end{center}
+\begin{center}
+%
+\irule{q \in \GP{string} \spc g_1, \cdots, g_m \in \GP{xgroup} \icr
+ (\G, \TT{[} q\ \TT{attr}\ g_1 \TT{]}) \daq S_1 \spc \cdots \spc
+ (\G, \TT{[} q\ \TT{attr}\ g_m \TT{]}) \daq S_m}{}
+ {(\G, \TT{[} q\ \TT{attr}\ g_1 \TT{,} \cdots \TT{,} g_m \TT{]}) \daq S_1 \ssum \cdots \ssum S_m}
+%
+\end{center}
+\begin{center}
+%
+\irule{q \in \GP{string} \spc a_1, \cdots, a_m \in \GP{xatr} \icr
+ (\G, \TT{[} q\ \TT{attr}\ \{ a_1 \} \TT{]}) \daq S_1 \spc \cdots \spc
+ (\G, \TT{[} q\ \TT{attr}\ \{ a_m \} \TT{]}) \daq S_m}{}
+ {(\G, \TT{[} q\ \TT{attr}\ \{ a_1 \TT{;} \cdots \TT{;} a_m \} \TT{]}) \daq S_1 \dsum \cdots \dsum S_m}
+%
+\end{center}
+\begin{center}
+%
+\irule{q \in \GP{string} \spc p \in \GP{path} \spc x \daq S}{}
+ {(\G, \TT{[} q\ \TT{attr}\ \{ p = x \} \TT{]}) \daq
+ \{(\Unquote\ q, \{ \{ (\Name\ p, \Fsts\ S) \} \})\}}
+%
+\end{center}
+\end{footnotesize}
+
+$ \dsum $ and $ \ssum $ are helper functions describing the two union
+operations on {\av} sets: with and without attribute distribution respectively.
+
+\begin{footnotesize}
+\begin{center} \begin{tabular}{lrll}
+%
+1a &
+$ (S_1 \sdor \{(r, A_1)\}) \ssum (S_2 \sdor \{(r, A_2)\}) $ & rewrites to &
+$ (S_1 \ssum S_2) \sor \{(r, A_1 \sor A_2)\} $ \\
+1b & $ S_1 \ssum S_2 $ & rewrites to & $ S_1 \sor S_2 $ \\
+2a &
+$ (S_1 \sdor \{(r, A_1)\}) \dsum (S_2 \sdor \{(r, A_2)\}) $ & rewrites to &
+$ (S_1 \dsum S_2) \sor \{(r, A_1 \distr A_2)\} $ \\
+2b & $ S_1 \dsum S_2 $ & rewrites to & $ S_1 \sor S_2 $
+%
+\end{tabular} \end{center}
+\end{footnotesize}
+
+Rules 1a, 2a override 1b, 2b and
+$ A_1 \distr A_2 = \{G_1 \ssum G_2 \st G_1 \in A_1, G_2 \in A_2\} $.
+
+\item
+The semantics of the \TT{property} operator is described below.
+
+In the following rule,
+$s$ is ``$ \TT{property}\ h\ p_1\ \TT{main}\ p_2\ \TT{attr}\ e_1, \cdots,
+e_m\ \TT{in}\ k\ x $'', $P$ is $ \Property\ h $ and
+$A_2$ is $ \{ \Exp\ P\ p_1\ r_1\ \{e_1, \cdots, e_m\}\} $:
+
+\begin{footnotesize}
+\begin{center}
+%
+\irule
+{h \oft \GP{ref} \spc p_1, p_2 \oft \GP{path} \spc
+ e_1, \cdots, e_m \oft \GP{exp} \spc k \in \TT{["pattern"]?} \spc
+ (\G, x) \daq S
+}{A}
+{(\G, s) \daq \bigsum \{ \{(r_2, A_2)\} \st
+(\lex r_1 \in \Src\ k\ P\ (\Fsts\ S))\
+(r_1, p_1 \app p_2, r_2) \in P
+\}}
+%
+\end{center}
+\end{footnotesize}
+
+When the \TT{main} clause is not present, we assume $ p_2 = \TT{/} $.
+
+Here $ \Property\ h $ gives the appropriate access relation according to
+the $ h $ flag (this is the primitive function that inspects the {\RDF}
+graph).
+
+$ \Src\ k\ P\ V $ is a helper function giving the source set
+according to the $ k $ flag. $ \Src $ is based on $ \Match $, the helper
+function handling {\POSIX} regular expressions.
+Here $ \Pattern\ W\ s $ is the primitive function returning the subset of
+$ W \oft \Setof\ \Str $ whose element match the {\POSIX} 1003.2-1992%
+\footnote{In {\POSIX} 1003.1-2001:
+\CURI{http://www.unix-systems.org/version3/ieee\_\,std.html}.}
+regular expression $ \verb+"^"+ \app s \app \TT{"\$"} $.
+
+\begin{footnotesize}
+\begin{center} \begin{tabular}{rll}
+%
+$ \Src\ \TT{""}\ P\ V $ & rewrites to & $ V $ \\
+$ \Src\ \TT{"pattern"}\ P\ V $ & rewrites to &
+$ \Match\ \{r_1 \st (\lex p, r2)\ (r_1, p, r_2) \in P\} $\ V \\
+$ \Match\ W\ V $ & rewrites to & $ \bigsor \{\Pattern\ W\ s \st s \in V\} $
+%
+\end{tabular} \end{center}
+\end{footnotesize}
+
+$ \Exp\ P\ p_1\ r_1\ E $ is the helper function that builds the group of
+attributes specified in the \TT{attr} clause.
+$ \Exp $ is based on $ \Exp\p $ which handles a single attribute. Formally,
+if $ p, p\p \oft \GP{path} $ and $ E \oft \Setof\ \GP{exp} $:
+
+\begin{footnotesize}
+\begin{center} \begin{tabular}{rll}
+%
+$ f\ P\ r_1\ p_1\ p $ & rewrites to &
+$ \{ r_2 \st (r_1, p_1 \app (\Name\ p), r_2) \in P \} $ \\
+$ \Exp\p\ P\ r_1\ p_1\ p $ & rewrites to &
+$ \{ (\Name\ p, f\ P\ r_1\ p_1\ p) \} $ \\
+$ \Exp\p\ P\ r_1\ p_1\ (p\ \TT{as}\ p\p) $ & rewrites to &
+$ \{ (\Name\ p\p, f\ P\ r_1\ p_1\ p) \} $ \\
+$ \Exp\ P\ r_1\ p_1\ E $ & rewrites to &
+$ \bigsum \{ \Exp\p\ P\ r_1\ p_1\ e \st e \in E \} $ \\
+\end{tabular} \end{center}
+\end{footnotesize}
+
+When $ c_1, \cdots, c_n \oft \GP{cons} $ and the clause
+``\TT{istrue} $ c_1, \cdots, c_n $'' is present, the set $ P $ must be replaced
+with $ \{ (r_1, p, r_2) \in P \st \Istrue\ P\ r_1\ p_1\ C \} $
+where $ C $ is $ \{c_1, \cdots, c_n\} $ and $ \Istrue $ is a helper function
+that checks the constraints in $ C $.
+$ \Istrue $ is based on $ \Istrue\p $ that handles a single constraint.
+Formally, if $ p \oft \GP{path} $ and $ (\G, x) \daq S $:
+
+\begin{footnotesize}
+\begin{center} \begin{tabular}{rll}
+%
+$ g\ P\ p_1\ p $ & rewrites to &
+$ \{ r_2 \st (\lex r_1)\ (r_1, p_1 \app (\Name\ p), r_2) \in P \} $ \\
+$ \Istrue\p\ P\ r_1\ p_1\ (p\ \TT{in}\ x) $ & rewrites to &
+$ (f\ P\ r_1\ p_1\ p) \meet \Fsts\ S $ \\
+$ \Istrue\p\ P\ r_1\ p_1\ (p\ \TT{match}\ x) $ & rewrites to &
+$ (f\ P\ r_1\ p_1\ p) \meet \Match\ (g\ P\ p_1\ p)\ (\Fsts\ S) $ \\
+$ \Istrue\ P\ r_1\ p_1\ C $ & rewrites to &
+$ (\lall c \in W)\ \Istrue\p\ P\ r_1\ p_1\ c $
+%
+\end{tabular} \end{center}
+\end{footnotesize}
+
+For each clause ``\TT{isfalse} $ c_1, \cdots, c_n $'' the set $ P $
+must be replaced with \newline
+$ \{ (r_1, p, r_2) \in P \st \lnot (\Istrue\ P\ r_1\ p_1\ C) \} $
+(using the above notation).
+Note that these substitutions and the former must be composed if necessary.
+
+If the \TT{inverse} flag is present, also replace the instances of $ P $ in
+the rule $A$ and in the definition of $ \Src $ with
+$ \{ (r_2, p, r_1) \st (r_1, p, r_2) \in P \} $.
+
+\end{itemize}
+
+The second group of \GP{query} expressions allows the context manipulation:
+
+\begin{itemize}
+
+\item
+The operators for reading variables:
+
+\begin{footnotesize} \begin{center}
+%
+\irule{i \oft \GP{svar}}{}{(\g, i) \daq \get{\G_s}{i}} \spc
+\irule{i \oft \GP{evar}}{}{(\g, i) \daq \{\get{\G_e}{i}\}}
+%
+\end{center} \end{footnotesize}
+
+$ \get{\G_s}{i} $ and $ \{\get{\G_e}{i}\} $ mean $ \ES $ if $ i $ is not defined.
+
+\item
+The \TT{let} operator assigns a set variable (\GP{svar}):
+
+\begin{footnotesize}
+\begin{center}
+%
+\irule{i \oft \GP{svar} \spc (\G_1, x_1) \daq (\g, S_1) \spc
+ ((\set{\G_s}{i}{S_1}, \G_e, \G_g), x_2) \daq (\G_2, S_2)}
+{}{(\G_1, \TT{let}\ i\ \TT{=}\ x_1\ \TT{in}\ x_2) \daq (\G_2, S_2)}
+%
+\end{center}
+\end{footnotesize}
+
+The sequential composition operator \TT{;;} has the semantics of a \TT{let}
+introducing a fresh variable, so ``$ x_1\ \TT{;;}\ x_2 $'' rewrites
+to ``$ \TT{let}\ i\ \TT{=}\ x_1\ \TT{in}\ x_2 $'' where $i$ does not occur in
+$x_2$.
+
+\item
+The \TT{ex} and ``dot'' operators provide a way to read the attributes stored
+in element variables.
+The \TT{ex} (exists) operator gives access to the groups of attributes
+associated to the {\av}'s in the $ \G_e $ part of the context and does
+this by loading its $ \G_g $ part, which is used by the ``dot'' operator
+described below.
+
+\TT{ex} is true if the query following it is successful for at least one
+pool of attribute groups, one for each {\av} in the $ \G_e $ part of the
+context. Formally we have the rules:
+
+\begin{footnotesize}
+\begin{center}
+%
+\irule{(\lall \D_g \in \All\ \G_e)\ ((\G_s, \G_e, \G_g + \D_g), y) \daq \F}
+ {1}{(\G, \TT{ex}\ y) \daq \F} \spc
+\irule{\Nop}{2}{(\G, \TT{ex}\ y) \daq \T} \spc
+%
+\end{center}
+\begin{center}
+%
+\irule {i \oft \GP{evar} \spc p \oft \GP{path} \spc \get{\get{\G_g}{i}}{\Name\ p} = \{s_1, \cdots, s_m\}}{}
+ {(\G, i\TT{.}p) \daq \{(s_1, \ES), \cdots, (s_m, \ES)\}}
+%
+\end{center}
+\end{footnotesize}
+
+where%
+\footnote{$\D_g$ has the type of $ \G_g $.}
+$ \All\ \G_e = \{\D_g \st \get{\D_g}{i} = G\ \RM{iff}\ G \in \Snd\ \get{\G_e}{i} \} $,
+and $ \G = \g $.
+
+Moreover $ \get{\get{\G_g}{i}}{\Name\ p} $ means $ \ES $
+if $ i $ or $ \Name\ p $ are not defined where appropriate.
+Here the first rule has higher precedence than the second one does.
+
+\end{itemize}
+
+The third group of \GP{query} expressions allows the {\av} set manipulation:
+
+\begin{itemize}
+
+\item
+The \TT{add} operator adds a given set of attribute groups to the {\av}'s
+of an {\av} set using a union with or without attribute distribution
+according to the setting of the \TT{distr} flag.
+
+\begin{footnotesize}
+\begin{center}
+%
+\irule
+{h \in \TT{["distr"]?} \spc a \in \GP{xgroups} \icr
+ (\G, \TT{[} ""\ \TT{attr}\ a \TT{]}) \daq \{("", A)\} \spc
+ (\G, x) \daq \{(r_1, A_1), \cdots, (r_m, A_m)\}}{}
+{(\G, \TT{add}\ a\ \TT{in}\ x) \daq \{(r_1, A_1 \jolly A), \cdots, (r_m, A_m \jolly A)\}}
+%
+\end{center}
+\begin{center}
+%
+\irule
+{h \in \TT{["distr"]?} \spc i \in \GP{evar} \spc
+ (\g, x) \daq \{(r_1, A_1), \cdots, (r_m, A_m)\}}{}
+{(\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})\}}
+%
+\end{center}
+\end{footnotesize}
+
+Where $ \jolly_{\tt""} = \sor $ and $ \jolly_{\tt"distr"} = \distr $.
+Moreover $ \Snd\ \get{\G_e}{i} = \ES $ if $i$ is not defined.
+
+\item
+The semantics of the \TT{for} operator is given using the {\For} helper
+function:
+
+\begin{footnotesize}
+\begin{center}
+%
+\irule{i \oft \GP{evar} \spc (\G, x_1) \daq (\G_1, S_1) \spc h \in \TT{["sup"|"inf"]}}
+{}{(\G, \TT{for}\ i\ \TT{in}\ x_1\ h\ x_2) \daq \For\ h\ \G_1\ i\ x_2\ S_1}
+%
+\end{center}
+\begin{center}
+%
+\irule{i \oft \GP{evar} \spc x_2 \oft \GP{query}}{}
+ {\For\ h\ \G\ i\ x_2\ \ES\ \RM{rewrites to}\ (\G, \ES)}
+%
+\end{center}
+\begin{center}
+%
+\irule{i \oft \GP{evar} \spc ((\G_s, \set{\G_e}{i}{R}, \G_g), x_2) \daq (\G_2, S_2)}
+ {}{\For\ h\ \G\ i\ x_2\ (S_1 \sdor \{R\})\ \RM{rewrites to}\
+ (\G_2 ,(\Snd\ (\For\ h\ \G_2\ i\ x_2\ S_1)) \jolly_h S_2)}
+%
+\end{center}
+\end{footnotesize}
+
+Here we have $ R \oft T_3 $, $ \G = \g $, $ \jolly_{\tt"sup"} = \ssum $ and
+$ \jolly_{\tt"inf"} = \sprod $.
+
+$ \dprod $ and $ \sprod $ are helper functions describing the two intersection
+operations on {\av} sets: with and without attribute distribution respectively.
+They are dual to $ \dsum $ and $ \ssum $. $ \dprod $ does not appear in this
+version of {\MathQL} but was used in the earlier versions
+\cite{Lor02,GS03,Gui03}.
+
+\begin{footnotesize}
+\begin{center} \begin{tabular}{lrll}
+%
+1a &
+$ (S_1 \sdor \{(r, A_1)\}) \sprod (S_2 \sdor \{(r, A_2)\}) $ & rewrites to &
+$ (S_1 \sprod S_2) \sor \{(r, A_1 \sor A_2)\} $ \\
+1b & $ S_1 \sprod S_2 $ & rewrites to & $ \ES $ \\
+2a &
+$ (S_1 \sdor \{(r, A_1)\}) \dprod (S_2 \sdor \{(r, A_2)\}) $ & rewrites to &
+$ (S_1 \dprod S_2) \sor \{(r, A_1 \distr A_2)\} $ \\
+2b & $ S_1 \dprod S_2 $ & rewrites to & $ \ES $
+%
+\end{tabular} \end{center}
+\end{footnotesize}
+
+As for $ \ssum $ and $ \dsum $, rules 1a, 2a override rules 1b, 2b respectively.
+
+\item
+The semantics of the \TT{while} operator is given by the rules below:
+
+\begin{footnotesize}
+\begin{center}
+%
+\irule{h \in \TT{["sup"|"inf"]} \spc (\G, x_1) \daq (\G_1, \ES)}{1}
+{(\G, \TT{while}\ x_1\ h\ x_2) \daq (\G_1, \ES)}
+%
+\end{center}
+\begin{center}
+%
+\irule
+{h \in \TT{["sup"|"inf"]} \spc (\G, x_1) \daq (\G_1, S_1) \spc
+ (\G_1, x_2) \daq (\G_2, S_2) \icr
+ (\G_2, \TT{while}\ x_1\ h\ x_2) \daq (\G_3, S)}{2}
+{(\G, \TT{while}\ x_1\ h\ x_2) \daq (\G_3, S_2 \jolly_h S)}
+%
+\end{center}
+\end{footnotesize}
+
+Again $ \jolly_{\tt"sup"} = \ssum $ and $ \jolly_{\tt"inf"} = \sprod $.
+Rule 1 takes precedence over rule 2.
+
+\end{itemize}
+
+The forth group of \GP{query} constructions makes {\MathQL} extensible.
+
+\begin{itemize}
+
+\item
+The ``function'' construction invokes an external function returning an {\av}
+set. The function is identified by a \GP{path} and its arguments are a set of
+\GP{path}'s and a set of \GP{query}'s. It is a mistake to invoke a function
+with the wrong number of \GP{path}'s and \GP{query}'s as input (each
+particular function defines these numbers independently).
+
+\begin{footnotesize}
+\begin{center}
+%
+\irule
+{p, p_1, \cdots, p_m \in \GP{path} \spc x_1, \cdots, x_n \in \GP{query}}{}
+{(\G, p\ \{p_1 \TT{,} \cdots \TT{,} p_m\}\ \{x_1 \TT{,} \cdots \TT{,} x_m\})
+ \daq \Fun\ p\ [p_1, \cdots, p_m]\ [x_1, \cdots, x_n]\ \G}
+%
+\end{center}
+\end{footnotesize}
+
+where $ \Fun \oft \GP{path} \times (\Listof\ \GP{path}) \times (\Listof\
+\GP{query}) \times K \to T_4 $ is the primitive function performing the
+low level invocation.
+The core language does not include any external function and it is a mistake
+to invoke an undefined function.
+
+\item
+The \TT{gen} construction invokes an external function returning a \GP{query}.
+The function is identified by a \GP{path} and its arguments are a set of
+\GP{query}'s. It is a mistake to invoke a function with the wrong number of
+\GP{query}'s as input (each particular function defines this number
+independently).
+
+\begin{footnotesize}
+\begin{center}
+%
+\irule
+{p \in \GP{path} \spc x_1, \cdots, x_n \in \GP{query} \spc
+ (\G, \Gen\ p\ [x_1, \cdots, x_n]\ \G) \daq (\G\p, S)}{}
+{(\G, \TT{gen}\ p\ \{x_1 \TT{,} \cdots \TT{,} x_m\}) \daq (\G\p, S)}
+%
+\end{center}
+\end{footnotesize}
+
+where $ \Gen \oft \GP{path} \times (\Listof\ \GP{query}) \times K \to
+\GP{query} $ is the primitive function performing the low level invocation.
+The core language does not include any external function of this kind and it
+is a mistake to invoke an undefined function.
+The construction ``\TT{gen} p \TT{in} x'' rewrites to ``\TT{gen} p \verb+{+x\verb+}+''.
+
+\end{itemize}
+
+\subsubsection*{Results}
+
+An \GP{avs} expression (the explicit representation of an {\av} set denoting a
+query result) is evaluated to an {\av} set according to the following rules.
+
+\begin{footnotesize}
+\begin{center}
+%
+\irule{x_1, \cdots, x_m \in \GP{av} \spc
+ x_1 \dar S_1 \spc \cdots \spc x_m \dar S_m}{}
+ {x_1 \TT{;} \cdots \TT{;} x_m \dar S_1 \ssum \cdots \ssum S_m}
+%
+\end{center}
+\begin{center}
+%
+\irule{q \in \GP{string} \spc g_1, \cdots, g_m \in \GP{group} \spc
+ q\ \TT{attr}\ g_1 \dar S_1 \spc \cdots \spc
+ q\ \TT{attr}\ g_m \dar S_m}{}
+ {q\ \TT{attr}\ g_1 \TT{,} \cdots \TT{,} g_m \dar S_1 \ssum \cdots \ssum S_m}
+%
+\end{center}
+\begin{center}
+%
+\irule{q \in \GP{string} \spc a_1, \cdots, a_m \in \GP{atr} \spc
+ q\ \TT{attr}\ \{ a_1 \} \dar S_1 \spc \cdots \spc
+ q\ \TT{attr}\ \{ a_m \} \dar S_m}{}
+ {(\G, q\ \TT{attr}\ \{ a_1 \TT{;} \cdots \TT{;} a_m \} \dar S_1 \dsum \cdots \dsum S_m}
+%
+\end{center}
+\begin{center}
+%
+\irule{q, q_0 \in \GP{string} \spc p \in \GP{path}}{}
+ {q\ \TT{attr}\ \{ p = q_0 \} \dar
+ \{(\Unquote\ q, \{ \{ (\Name\ p, \{ \Unquote\ q_0 \}) \} \})\}}
+%
+\end{center}
+\begin{center}
+%
+\irule{q, q_1, \cdots, q_m \in \GP{string} \spc p \in \GP{path}}{}
+ {q\ \TT{attr}\ \{ p = \{ q_1 \TT{,} \cdots \TT{,} q_m \} \} \dar
+ \{(\Unquote\ q, \{ \{ (\Name\ p, \{ \Unquote\ q_1, \cdots, \Unquote\ q_m \}) \} \})\}}
+%
+\end{center}
+\end{footnotesize}
--- /dev/null
+\subsection {The basic library}
--- /dev/null
+\section{Overview}
+
+{\MathQL}%
+\footnote{See \CURI{http://helm.cs.unibo.it/mathql}.}
+is a query language for {\RDF} \cite{RDF,RDFS} databases, developed in the
+context of the {\HELM}%
+\footnote{See \CURI{http://helm.cs.unibo.it}.}
+project \cite{APSCGS03}.
+Its name suggests that it is supposed to be the first of a group of query
+languages for retrieving information from distributed digital libraries of
+formal mathematical knowledge by means of content-aware requests, but no other
+languages of this proposal have been implemented yet except for {\MathQL} that
+is not Mathematics-oriented. So the name is a bit misleading.
+This proposal has several domains of application and may be useful for
+database or on-line libraries reviewers, for proof assistants or
+proof-checking systems, and also for learning environments because these
+applications require features for classifying, searching and browsing
+mathematical information in a semantically meaningful way.
+Other languages to be defined in the context of the MathQL proposal may be
+suitable for queries about the semantic structure of mathematical data:
+this includes content-based pattern-matching and possibly other forms of
+formal matching involving for instance isomorphism, unification and
+$\delta$-expansion%
+\footnote{By $\delta$-expansion we mean the expansion of definitions.}.
+In this perspective the role of a query on metadata is that of producing a
+filtered knowledge base containing relevant information for subsequent queries
+of other kind (see \cite{GSC03} for a more detailed description of this
+approach).
+
+{\MathQL} is carefully designed for making up for two limitations that seem to
+characterize several implementations and proposals of current {\RDF}-oriented
+query languages, namely the insufficient compliance with the most requested
+features and the poor attention paid to query result management.
+Thus the language has the following design goals:
+
+\begin{enumerate}
+
+\item
+compliance with the main requirements stated by the {\RDF} community;
+
+\item
+native support for post-processing the query results;
+
+\item
+{\HELM}-independent implementation of the query engine.
+
+\end{enumerate}
+
+We will briefly analyze these features in the remaining part of this
+section.
+
+\vspace{-1pc}
+
+\subsubsection*{The main requirements from the RDF community}
+
+As a query language for {\RDF} databases, {\MathQL} has a well-conceived
+semantics, defined in term of an abstract metadata model, according to which
+queries return exhaustive solutions.
+The language provides facilities for imposing query constraints based on
+{\RDFS} \cite{RDFS} and for the traversal of compound values of properties.
+It also provides a full set of Boolean operators to compose the query
+constraints and facilities for selecting resources or literals by means of
+{\POSIX} regular expressions.
+Moreover the language allows to customize the query results specifying what
+part of a solution should be preserved, and supports a machine-processable
+{\XML} \cite{XML} syntax as well as a human-readable textual syntax to achieve
+the best usability.
+The two syntaxes concern both queries and results, making {\MathQL} usable in
+a distributed environment where query engines are implemented as stand-alone
+components. In this setting in fact both the queries and their results must be
+exchanged by the system's components and thus need to be clearly encoded.
+
+{\MathQL} provides a graph-oriented access to the {\RDF} metadata, based on
+tree instantiation.
+This approach has the advantage of providing an abstraction over the
+concrete representation of the {\RDF} database (that can consist of {\RDF}
+triples and {\XML} files simultaneously) at the user level, and this is
+definitely desirable especially in a distributed context.
+
+{\MathQL} query results are meant to capture the structure of trees coming
+from an {\RDF} graph and for this purpose a standard $1$- or $2$-dimensional
+organization (as provided by most {\RDF}-oriented query languages) is not
+satisfactory. {\MathQL} approach is to use a $4$-dimensional organization
+for its query results.
+
+\vspace{-1pc}
+
+\subsubsection*{Post-processing and code generation capabilities}
+
+The {\MathQL} query engine, that is written in {\CAML}%
+\footnote{See \CURI{http://caml.inria.fr}.}
+for an easy integration with the {\HELM} software, provides two ways of
+processing the query results: at {\CAML} side and natively.
+
+At {\CAML} side, an application issues a query calling a function of the
+engine and manipulates the result either operating directly on its internal
+representation (through a low-level interface), or using a set of dedicated
+functions specifically designed to manage the query results.
+This set of functions includes a basic library but is extensible depending
+on the {\CAML} modules included in the engine at compile-time. In this way
+an expert user can write a {\CAML} module with new dedicated functions and can
+include it in the engine recompiling it.
+
+{\MathQL} supports native post-processing of the query results including the
+standard constructions of an imperative Turing-complete programming language,
+whose aim is definitely not that of being all-purpose (the user can work at
+{\CAML} side for that), but of being optimized for the management of the
+query results.
+In this context an {\SQL}-like ``select-from-where'' construction is provided
+(as required by the {\RDF} community) as well as a mechanism for accessing the
+post-processing dedicated functions available to the engine.
+
+Moreover the language provides access to an extensible set of code-generating
+functions (also available at {\CAML} side) that the expert user can define
+writing suitable {\CAML} modules for the engine.
+Note that the generated code is always {\MathQL} code.
+The code generation features allow to build complex queries incrementally and
+in an automatic manner, as required by the needs of the {\HELM} project.
+Using the native programming language, instead, queries can include the
+post-processing algorithms on their results so the querying code and the
+subsequent processing code (if needed) are treated together as a
+self-contained object that can be computed by a single engine.
+In this sense the alternative of performing a complex query on a remote
+component issuing some {\MathQL} querying code followed by some {\CAML}
+post-processing code is really infeasible in a distributed context.
+
+\vspace{-1pc}
+
+\subsubsection*{Physical organization of the RDF database}
+
+The implementation of the {\MathQL} query engine does not depend on any
+software developed within the {\HELM} project, nor it depends on the {\HELM}
+metadata model in any way.
+
+However the engine does make few assumptions on the way metadata are
+physically organized and needs some user-provided knowledge about the concrete
+metadata representation.
+Metadata stored as {\RDF} triples are accessed through a {\MySQL}%
+\footnote{See \CURI{http://www.mysql.com}.}
+or a {\PostgreSQL}%
+\footnote{See \CURI{http://www.postgresql.org}.}
+engine, while metadata stored as {\RDF}/{\XML} files are accessed through a
+{\Galax}%
+\footnote{See \CURI{http://db.bell-labs.com/galax/}.}
+{\XQuery} \cite{XQuery} engine.
--- /dev/null
+\section{A use case: retrieving the transitive principles}
+
+In this section we briefly present one on the many queries that we are using
+to test {\MathQL}.4: the one that retrieves the transitive principles stored
+in the {\HELM} library. The details on the {\RDF} metadata used to index the
+contents of the library can be found in \cite{Sch02,Gui03,GSC03}.
+This query, executed in {\MySQL}-mode on an AMD Athlon 1.5 GHz, retrieved
+$55$ {\HELM} objects (out of $41451$) in $4.00s$ (the interpreter worked
+for $0.31s$) after having issued $2205$ {\SQL} queries to the underlying
+database. This test was executed on April 2 2004 by the Author.
+
+\begin{footnotesize} \begin{verbatim}
+gen /"helm"/"aliases" in let $sets = property inverse /"refSort" istrue
+/"h:sort" in $SET, /"h:position" in $MC, /"h:depth" in "0" of "" in let
+$prop = property inverse /"refSort" istrue /"h:sort" in $PROP,
+/"h:position" in $MC, /"h:depth" in "2" of "" in let $rels0 = for @uri
+in $prop sup add {/"set" = property /"refObj" main /"h:occurrence" istrue
+/"h:position" in $MH of @uri} in @uri in let $rels = select @uri from
+$rels0 where ex ((count @uri./"set" eq "1") and (@uri./"set" sub $sets))
+in let $trans0 = for @uri in $rels sup add {/"rel" = @uri; /"set" = proj
+/"set" of @uri} in property inverse /"refObj" main /"h:occurrence" istrue
+/"h:position" in $MC, /"h:depth" in "5" of @uri in let $trans1 = for @uri
+in $trans0 sup add distr {/"premises" = property /"refObj" main /"h:occur
+rence" istrue /"h:position" in $MH of @uri; /"extra" = property /"refObj"
+main /"h:occurrence" istrue /"h:position" in {$IC, $IH} of @uri} in @uri
+in let $trans = select @uri from $trans1 where ex (not @uri./"extra" and
+(@uri./"premises" sub {@uri./"rel", @uri./"set"})) in keep $trans
+\end{verbatim} \end{footnotesize} %$
+
+\input{mathql_tests_transitive}
--- /dev/null
+GRAMMATICA PER QUERY SU DOCUMENTI MATEMATICI
+MATHEMATICAL QUERY LANGUAGE (MathQL)
+
+<query> := <set> (* clausola iniziale *)
+
+<set> := ( <set> ) (* parentesizzazione *)
+ | <rvar> (* var per insieme singoletto
+ di una risorsa *)
+ | <svar> (* var per insieme di risorse
+ (insieme di valori) *)
+ | REF <string-set> (* oggetto/i referenziato/i da
+ URI esplicita/e *)
+ | PATTERN <string-set> (* oggetto/i referenziato/i da
+ URI ottenute da espansione
+ del pattern *)
+ | SELECT <rvar> IN <set> WHERE <bool> (* selezione *)
+ | LET <svar> BE <set> IN <set> (* assegnazione a set-var in
+ contesto *)
+ | LET <vvar> BE <string-set> IN <set> (* assegnamento a value-var
+ in contesto*)
+ | RELATION <refine_op> <quoted-constant-string-path> <set> ATTR <vvar-list>
+ (* unione insieme risorse in
+ relazione specificata con le
+ risorse in set, ognuna con
+ attributi (ATTR) *)
+ | <set> UNION <set> (* unione *)
+ | <set> INTERSECT <set> (* intersezione *)
+ | <set> DIFF <set> (* differenza *)
+
+<refine_op> := "" (* relazione (proprieta') *)
+ | SUB (* proprieta' e
+ sotto-proprieta' *)
+ | SUPER (* proprieta' e
+ super-proprieta' *)
+
+<quoted-constant-string-path> := <quoted-constant-string>
+ (* relazione (proprieta') *)
+ | <quoted-constant-string> "/" <quoted-constant-string-path>
+ (* insieme di stringhe:
+ proprieta' strutturata *)
+
+<vvar-list> := <vvar>
+ | <vvar> , <vvar-list>
+
+
+<bool> := ( <bool> ) (* parentesizzazione *)
+ | TRUE (* vero *)
+ | FALSE (* falso *)
+ | NOT <bool> (* negazione *)
+ | <bool> AND <bool> (* congiunzione *)
+ | <bool> OR <bool> (* disgiunzione *)
+ | <string-set> EQ <string-set> (* uguaglianza tra insiemi
+ stringhe (case sensitive) *)
+ | <string-set> SUB <string-set> (* operazione di sottoinsieme
+ tra insiemi stringhe *)
+ | <string-set> MEET <string-set> (* operazione di meet tra
+ insiemi stringhe *)
+ | EX <bool> (* existential on attributes
+ of references *)
+<string-set> := ( <string-set> ) (* parentesizzazione *)
+ | {} (* insieme vuoto*)
+ | <quoted-constant-string> (* stringa singoletto *)
+ | {<quoted-constant-string-list>}(* insieme stringhe *)
+ | REFOF <set> (* insieme riferimenti *)
+ | <rvar>.<vvar> (* variabile per insieme
+ stringhe, relativa a
+ riferimento *)
+ | <function> <quoted-constant-string> <string-set>
+ (* applicazione di funzione
+ specificata a riferimento
+ o insiemi di rif. o var*)
+ | <vvar> (* vvar introduced by LET *)
+
+<quoted-constant-string-list> := <quoted-constant-string>
+ | <quoted-constant-string> , <quoted-constant-string-list>
+ (* lista di stringhe *)
+
+<function> := FUN (* funzione generale *)
+ | <property>
+
+<property> := ATTRIBUTE <refine-op> (* funzione proprieta': restituisce
+ suoi valori (anche strutturati)
+ (e delle sotto-proprieta' o
+ super-proprieta' *)
+
+
+<rvar> := @ <not-reserved-identifier> (* variabile per riferimento *)
+<vvar> := $ <not-reserved-identifier> (* variabile per insiemi
+ stringhe *)
+<svar> := % <not-reserved-identifier> (* variabile per insiemi
+ riferimenti *)
+
+
+- Idea di base: grammatica del linguaggio semplice e permissiva (duttile)
+- MEET e' definito come "esiste almeno un elemento che appartiene
+ all'interserzione tra due insiemi"
+- le stringhe sono "case sensitive"
+- la funzione non definita sull'argomento restituisce la stringa nulla
+- le <rvar> si presuppongono essere istanziate come URI references costituite
+ da un URI e da un fragment identifier opzionale complete; i riferimenti
+ identificano risorse
+- Precedenza operatori:
+ NOT (+) DIFF
+ AND INTERSECT
+ OR (-) UNION
+- L'ordinamento di default e' quello alfabetico crescente in base al nome
+ delle rvar
+- REF aumenta performance perche' NON accede al data base (costoso).
+- l'argomento di PATTERN ha sintassi di una espressione regolare
+ POSIX 1003.2-1992
+- Possibile FUN (<quoted-constant-string>):
+ NAME (* URIREF -> nome_oggetto *)
+- MEET aumenta performance nel caso si verifichi (a in S) oppure
+ (b in S) = ({a,b} meet S) perche' valuta S una volta sola
+ Il MEET codifica inoltre l'esistenziale su risorse (URI) in un certo
+ insieme che soddisfa certe condizioni
+- record <rvar>.<svar> serve per disambiguare nomi uguali di variabili
+- Operatori (come EQ) hanno nomi abbreviati rispetto ai costrutti del
+ linguaggio
+- EX verfica che la sua condizione sia vera per almeno un insieme di attributi
+ associato all'URI in rvar
+- Possibili RELATION sono:
+ USE con attributo POSITION (riferimenti backward) e valori MAINHYPOTHESIS,
+ HYPOTHESIS, MAINCONCLUSION, CONCLUSION, BODY
+ USEBY con attributo POSITION (riferimenti forward) e valori MAINHYPOTHESIS,
+ HYPOTHESIS, MAINCONCLUSION, CONCLUSION, BODY
+ CONSTRUCTORS
+ INTHEORY con attributo ITEMTYPE (riferimenti oggetti contenuti in teorie)
+ THEORYREFTO con attributo ITEMTYPE (riferimenti teorie referenti a oggetti)
+- <string-set> invece di <set> come argomento di <function> poiche' la REF non
+ e' piu' restrittiva su argomento/i e quindi e' inutile imporne l'uso quando
+ si passano i riferimenti alle funzioni. Con <string-set> l'utente e' libero
+ di passare direttamente le stringhe dei riferimenti.
+- Il costrutto di ordinamento:
+ <set> SORTEDBY <function> <order> (* unione insieme ordinato secondo
+ valore funzione e ordine *)
+ <order>:= DESC (* ordinamento decrescente *)
+ | ASC (* ordinamento crescente *)
+ perde di senso nel caso di metadati, poiche' per definizione le proprieta'
+ in RDF possono essere ripetute quindi restituiscono (come anche le funzioni
+ in generale) valori multipli per ogni riferimento (ambiguita' nell'ordine)
+- Possibili proprieta' (<quoted-constant-string>):
+ le DC: TITLE, CONTRIBUTOR, CREATOR, PUBLISHER, SUBJECT, DESCRIPTION, DATE,
+ TYPE, FORMAT, IDENTIFIER, LANGUAGE, RELATION, SOURCE, COVERAGE, RIGHTS,
+ RIGHTS; and INSTITUTION, CONTACT, FIRSTVERSION, MODIFIED, THEORY
+- Il concetto di Classe, sottoclasse, superclasse, puo' essere visto come una
+ particolare proprieta' (type o tipo) di una risorsa, e quindi codificabile
+ da RELATION
\ No newline at end of file
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <title>MathQL</title>
+
+ <meta http-equiv="content-type"
+ content="text/html; charset=ISO-8859-1">
+
+ <meta name="author" content="Ferruccio Guidi">
+
+ <meta name="description" content="MathQL Home Page">
+</head>
+ <body>
+
+<h1 align="center">MathQL-1</h1>
+
+<h2 align="center">A query language for RDF metadata</h2>
+
+<table cellpadding="10" cellspacing="2" border="0" width="95%"
+ bgcolor="#ffffff">
+ <tbody>
+ <tr>
+ <td valign="top" align="left">
+
+ <ul>
+ <li><a href="index.html">Forward</a><br>
+ </li>
+
+
+ </ul>
+
+ <ul>
+ <li><a href="features.html">Features</a></li>
+
+ </ul>
+
+ <ul>
+ <li><a href="whatsnew.html">What's new</a><br>
+ </li>
+
+ </ul>
+
+ <ul>
+ <li><a href="documentation.html">Documentation</a></li>
+
+
+ </ul>
+
+ <ul>
+ <li><a href="implementation.html">Implementation</a><br>
+ </li>
+
+ </ul>
+
+ <ul>
+ <li>The authors<br>
+ </li>
+
+
+ </ul>
+
+ <ul>
+ <li><a href="links.html">Links</a><br>
+ </li>
+
+ </ul>
+ <br>
+ </td>
+ <td valign="top">
+
+ <div align="right"><b>The authors</b><br>
+ </div>
+ <br>
+ MathQL-1is developed by <a
+ href="http://www.cs.unibo.it/%7Efguidi/">Ferruccio Guidi</a> and <a
+ href="http://www.cs.unibo.it/%7Eschena/">Irene Schena</a> at the <a
+ href="http://www.cs.unibo.it/">Department of Computer Science</a> of the
+ <a href="http://www.unibo.it/">University of Bologna</a> since April
+ 2002.<br>
+ <br>
+ <b>Ferruccio Guidi</b> obtained a Master degree in Mathematics
+at the University of Padova and a PhD in Computer Science at the University
+ of Bologna. His research interests include computer-assisted proof development,
+ Martin-Löf type theory and substructural logic. He is a member of
+the <a href="http://helm.cs.unibo.it/">HELM Working Group</a> and of
+the <a href="http://www.math.unipd.it/%7Elogic/">"Paulus Venetus" Research
+Group in Logic</a>.<br>
+ <br>
+ <b>Irene Schena</b> obtained a Master Degree in Computer Science
+and a Ph.D. in Computer Science at the University of Bologna. Her research
+interests include Linear Logic and Web Technologies. She is a member of the
+ <a href="http://helm.cs.unibo.it/">HELM Working Group</a> and of the
+ <a href="http://www.w3c.org/Math">W3C Math Working Group</a>.<br>
+ <br>
+ <b>Contacts:</b> <a href="mailto://fguidi@cs.unibo.it">fguidi@cs.unibo.it</a>,
+ <a href="mailto://schena@cs.unibo.it">schena@cs.unibo.it</a>.<br>
+ </td>
+ </tr>
+
+ </tbody>
+</table>
+ <br>
+</body>
+</html>
--- /dev/null
+<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+
+ <meta http-equiv="Content-Type"
+ content="text/html; charset=iso-8859-1">
+
+ <meta http-equiv="content-type"
+ content="text/html; charset=ISO-8859-1">
+
+ <meta name="author" content="Ferruccio Guidi">
+
+ <meta name="description" content="MathQL Home Page">
+
+ <meta name="GENERATOR"
+ content="Mozilla/4.77 [en] (X11; U; Linux 2.4.20-cs-p3 i686) [Netscape]">
+ <title>MathQL</title>
+</head>
+ <body>
+
+<center>
+<h1> MathQL-1</h1>
+ </center>
+
+<center>
+<h2> A query language for RDF metadata</h2>
+ </center>
+ <br>
+
+<table border="0" cellspacing="2" cellpadding="10" width="95%"
+ bgcolor="#ffffff">
+ <caption><br>
+ </caption><tbody>
+
+ </tbody> <tbody>
+ <tr>
+ <td align="left" valign="top">
+ <ul>
+ <li> <a href="index.html">Forward</a></li>
+
+ </ul>
+
+ <ul>
+ <li> <a href="features.html">Features</a></li>
+
+ </ul>
+
+ <ul>
+ <li> <a href="whatsnew.html">What's new</a></li>
+
+ </ul>
+
+ <ul>
+ <li> Documentation</li>
+
+ </ul>
+
+ <ul>
+ <li> <a href="implementation.html">Implementation</a></li>
+
+ </ul>
+
+ <ul>
+ <li> <a href="authors.html">The authors</a></li>
+
+ </ul>
+
+ <ul>
+ <li> <a href="links.html">Links</a></li>
+
+ </ul>
+ </td>
+ <td valign="top">
+ <div align="right"><b>Documentation</b></div>
+
+ <p><br>
+ All available information about MathQL-1 can be found in the papers below
+ (listed in order of relevance). <br>
+ The newest features of MathQL-1, which are not included in this documentation,
+ are reported in the <a href="whatsnew.html">What's new</a> section. </p>
+
+ <p><b>Papers concerning the developement version of MathQL-1:</b> </p>
+
+ <ul>
+ <li> F. Guidi: <a
+ href="http://www.cs.unibo.it/%7Efguidi/download/aql2_s.ps"><i>Reperimento
+ delle Informazioni nelle Librerie Digitali Distribuite di Conoscenza Matematica
+ Formale</i></a>. Presentation at McTati Meeting November 2003. Bologna.
+Italy. <u>Italian version.</u></li>
+
+ <p>The English version will be available soon.</p>
+
+ </ul>
+ <b>Papers concerning the latest stable version of MathQL-1:</b>
+
+ <ul>
+ <li> F. Guidi: <i><a
+ href="http://www.cs.unibo.it/techreports/2003/2003-06.ps.gz">Searching and
+ Retrieving in Content-based Repositories of Formal Mathematical Knowledge</a></i>.
+ Ph.D. Thesis in Computer Science, University of Bologna, March 2003. Technical
+ report UBLCS 2003-06.</li>
+
+ </ul>
+
+ <ul>
+ <li> F. Guidi and I. Schena: <i><a
+ href="http://monet.nag.co.uk/mkm/bertinoro03/guidi.pdf">A Query Language
+ for a Metadata Framework about Mathematical Resources</a></i>. Presentation
+ at the 2nd International Conference on Mathematical Knowledge Management
+(MKM 2003). Bertinoro, Italy, February 2003.</li>
+
+ </ul>
+ <b>Papers concerning the earlier versions of MathQL-1:</b>
+
+ <ul>
+ <li> F. Guidi and I. Schena: <i>A Query Language for a Metadata Framework
+ about Mathematical Resources</i>. In Proc. of the 2nd International Conference
+ on Mathematical Knowledge Management (MKM 2003). Bertinoro, Italy, February
+ 2003. LNCS 2594, pages 105-118, Springer. 2003.</li>
+
+ </ul>
+
+ <ul>
+ <li> F. Guidi and I. Schena: <i><a
+ href="http://www.cs.unibo.it/%7Efguidi/download/aql_s.ps">Advancement on
+ a Query Language for Metadata</a></i>. Presentation at MOWGLI Meeting July
+ 2002. Eindhoven, the Netherlands.</li>
+
+ </ul>
+
+ <ul>
+ <li> L. Natile: <i><a
+ href="http://www.cs.unibo.it/%7Efguidi/download/tesi-natile.ps">Tecnologie
+ per l'Interrogazione di Basi Documentarie in Formato XML</a></i>. Master
+Thesis in Computer Science, University of Bologna, 2002.</li>
+
+ </ul>
+
+ <ul>
+ <li> A. Nediani: <i><a
+ href="http://www.cs.unibo.it/%7Efguidi/download/tesi-nediani.zip">Disegno
+ e Implementazione di un'Interfaccia Web di Supporto ad Interrogazioni su
+Basi di Dati Documentarie</a></i>. Master Thesis in Computer Science, University
+ of Bologna, 2003.</li>
+
+ </ul>
+
+ <ul>
+ <li> D. Lordi: <i><a
+ href="http://www.cs.unibo.it/%7Efguidi/download/tesi-lordi.pdf">Sperimentazione
+ e Sviluppo di Strumenti per la gestione di metadati</a></i>. Master Thesis
+ in Computer Science, University of Bologna, 2002.</li>
+
+ </ul>
+ </td>
+ </tr>
+
+ </tbody>
+</table>
+ <br>
+ <br>
+ <br>
+</body>
+</html>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <title>MathQL</title>
+
+ <meta http-equiv="content-type"
+ content="text/html; charset=ISO-8859-1">
+
+ <meta name="author" content="Ferruccio Guidi">
+
+ <meta name="description" content="MathQL Home Page">
+</head>
+ <body>
+
+<h1 align="center">MathQL-1</h1>
+
+<h2 align="center">A query language for RDF metadata</h2>
+
+<table cellpadding="10" cellspacing="2" border="0" width="95%"
+ bgcolor="#ffffff">
+ <tbody>
+ <tr>
+ <td valign="top" align="left">
+
+ <ul>
+ <li><a href="index.html">Forward</a><br>
+ </li>
+
+ </ul>
+
+ <ul>
+ <li>Features</li>
+
+ </ul>
+
+ <ul>
+ <li><a href="whatsnew.html">What's new</a></li>
+
+ </ul>
+
+ <ul>
+ <li><a href="documentation.html">Documentation</a></li>
+
+ </ul>
+
+ <ul>
+ <li><a href="implementation.html">Implementation</a><br>
+ </li>
+
+ </ul>
+
+ <ul>
+ <li><a href="authors.html">The authors</a><br>
+ </li>
+
+ </ul>
+
+ <ul>
+ <li><a href="links.html">Links</a><br>
+ </li>
+
+ </ul>
+ <br>
+ </td>
+ <td valign="top">
+
+ <div align="right"><b>Goals and features</b><br>
+ </div>
+ <br>
+ MathQL-1 is designed to achieve the following goals:<br>
+
+ <ol>
+ <li>Exploitation of <a href="http://www.w3.org/RDF/">RDF</a> technology
+ to manage metadata and <b>compliance with the main requirements</b> for an
+ RDF query language. In particular:</li>
+
+ </ol>
+
+ <blockquote>
+ <ul>
+ <li>MathQL-1 provides facilities for hierarchical constraints
+ based on <a href="http://www.w3.org/TR/rdf-schema/">RDF Schema</a> and for
+ traversal of compound values of properties.</li>
+
+ </ul>
+
+ <ul>
+ <li>MathQL-1 provides a full set of Boolean operators to compose
+ the query constraints and facilities for selecting URI's or literals by means
+ of regular expressions.</li>
+
+ </ul>
+
+ <ul>
+ <li>MathQL-1 allows to customize the query results specifying
+ what part of a solution should be preserved or discarded.</li>
+
+ </ul>
+
+ <ul>
+ <li>MathQL-1 has a well-conceived semantics defined in term
+of an abstract metadata model, imposes that queries return exhaustive solutions
+ and includes a "select-from-where"-like construction.</li>
+
+ </ul>
+
+ <ul>
+ <li>MathQL-1 supports a machine-processable <a
+ href="http://www.w3.org/XML/">XML</a> syntax as well as a human-readable
+ textual syntax to achieve the best usability.<br>
+ </li>
+
+ </ul>
+ </blockquote>
+
+ <ol start="2">
+ <li>Careful <b>treatment of query results</b> that are as important
+ as the queries themselves. In particular:<br>
+ </li>
+
+ </ol>
+
+ <blockquote>
+ <ul>
+ <li>MathQL-1 query results have a 4-dimensional geometry whereas
+ other languages assume that query results are returned in 1-dimensional structures
+ (i.e. lists of resources) or 2-dimensional structures (i.e. relational database
+ tables). This allows to get better outcomes from queries returning structured
+ results.<br>
+ </li>
+
+ </ul>
+
+ <ul>
+ <li>Besides the syntax for queries, MathQL-1 provides a syntax
+ for query results with its own rigorously defined semantics.<br>
+ </li>
+
+ </ul>
+ </blockquote>
+
+ <ol start="3">
+ <li>Exploitation of <b>constructions borrowed from programming
+languages</b> to allow sophisticated queries that need computation over the
+queried data. In particular:<br>
+ </li>
+
+ </ol>
+
+ <blockquote>
+ <ul>
+ <li>MathQL-1 supports variables for storing intermediate query
+ results, provides iterators over these results, has a conditional operator
+ and includes logging facilities for debugging purposes.</li>
+
+ </ul>
+ </blockquote>
+ </td>
+ </tr>
+
+ </tbody>
+</table>
+ <br>
+</body>
+</html>
--- /dev/null
+<!DOCTYPE doctype PUBLIC "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+
+ <meta http-equiv="Content-Type"
+ content="text/html; charset=iso-8859-1">
+
+ <meta http-equiv="content-type"
+ content="text/html; charset=ISO-8859-1">
+
+ <meta name="author" content="Ferruccio Guidi">
+
+ <meta name="description" content="MathQL Home Page">
+
+ <meta name="GENERATOR"
+ content="Mozilla/4.77 [en] (X11; U; Linux 2.4.20-cs-p3 i686) [Netscape]">
+ <title>MathQL</title>
+</head>
+ <body>
+
+<center>
+<h1> MathQL-1</h1>
+ </center>
+
+<center>
+<h2> A query language for RDF metadata</h2>
+ </center>
+ <br>
+
+<table border="0" cellspacing="2" cellpadding="10" width="95%"
+ bgcolor="#ffffff">
+ <caption><br>
+ </caption><tbody>
+
+ </tbody> <tbody>
+ <tr>
+ <td align="left" valign="top">
+ <ul>
+ <li> <a href="index.html">Forward</a></li>
+
+ </ul>
+
+ <ul>
+ <li> <a href="features.html">Features</a></li>
+
+ </ul>
+
+ <ul>
+ <li> <a href="whatsnew.html">What's new</a></li>
+
+ </ul>
+
+ <ul>
+ <li> <a href="documentation.html">Documentation</a></li>
+
+ </ul>
+
+ <ul>
+ <li> Implementation</li>
+
+ </ul>
+
+ <ul>
+ <li> <a href="authors.html">The authors</a></li>
+
+ </ul>
+
+ <ul>
+ <li> <a href="links.html">Links</a></li>
+
+ </ul>
+ </td>
+ <td valign="top">
+ <div align="right"><b>Implementation</b></div>
+
+ <p><br>
+ The <b>MathQL-1 Suite for HELM</b> is implemented in <a
+ href="http://caml.inria.fr/">Caml</a> and is currently available through
+the <a href="http://www.cs.unibo.it/cgi-bin/cvsweb/helm/">HELM CVS repository</a>.
+The Suite provides the following software components: </p>
+
+ <ol>
+ <li> The basic Caml package for MathQL-1 (<a
+ href="http://www.cs.unibo.it/cgi-bin/cvsweb/helm/ocaml/mathql/">mathql</a>)
+ provides a <a href="http://helm.cs.unibo.it/">HELM</a> independent Caml
+representation of queries and query results, plus some general purpose utilities.</li>
+
+ </ol>
+
+ <ol start="2">
+ <li> The MathQL-1 interpreter (<a
+ href="http://www.cs.unibo.it/cgi-bin/cvsweb/helm/ocaml/mathql_interpreter/">mathql_interpreter</a>)
+provides the proper search engine and is now HELM independent.</li>
+ </ol>
+ <ol start="3">
+ <li>The HELM query generator (<a
+ href="http://www.cs.unibo.it/cgi-bin/cvsweb/helm/ocaml/mathql_generator/">mathql_generator</a>)
+ allows to build specific kinds of MathQL-1 queries, which are meaningful
+in the context of HELM, starting from a high-level description of the wanted
+ results. These queries are described at an abstract level in the following
+ paper:</li>
+
+ </ol>
+
+ <blockquote>
+ <ul>
+ <li> F. Guidi and C. Sacerdoti Coen: <i>Querying Distributed Digital Libraries
+ of Mathematics</i>. In Proc. of the 11th Symposium on the Integration of
+Symbolic Computation and Mechanized Reasoning (Calculemus 2003). Rome, Italy,
+September 2003. pages 17-30, Aracne. 2003.</li>
+
+ </ul>
+ </blockquote>
+
+ <ol start="4">
+ <li> The testing software for the MathQL-1 Suite (<a
+ href="http://www.cs.unibo.it/cgi-bin/cvsweb/helm/mathql_test/">mathql_test</a>)
+ provides three textual interfaces (one for the basic package, one for the
+ interpreter and one for the query generator) with specific features meant
+ for testing.</li>
+
+ </ol>
+ The current version of the Suite, realized entirely by F. Guidi, implements
+ MathQL-1 version 3 (i.e. MathQL-1.3). The newly implemented features, which
+ are not included in the official <a href="documentation.html">documentation</a>
+ yet, are reported in the <a href="whatsnew.html">What's new</a> section.
+
+ <p>The latest <a
+ href="http://mowgli.cs.unibo.it:58085/getpage?url=index.html&preprocess=true&param.processorURL=http%3A//mowgli.cs.unibo.it%3A58080/&param.getterURL=http%3A//mowgli.cs.unibo.it%3A58081/&param.proofcheckerURL=http%3A//mowgli.cs.unibo.it%3A58084/&param.draw_graphURL=http%3A//mowgli.cs.unibo.it%3A58083/&param.uri_set_queueURL=http%3A//mowgli.cs.unibo.it%3A58082/&param.UNICODEvsSYMBOL=unicode&param.keys=d_c%2CC1%2CHC2%2CL&param.thkeys=T1%2CT2%2CL%2CE&param.embedkeys=d_c%2CTC1%2CHC2%2CL&param.doctype-public=-//W3C//DTD%20XHTML%201.0%20Transitional//EN&param.encoding=iso-8859-1&param.thencoding=iso-8859-1&param.media-type=text/html&param.thmedia-type=text/html&param.interfaceURL=http%3A//helm.cs.unibo.it/helm/html/cic/index.html&param.thinterfaceURL=http%3A//helm.cs.unibo.it/helm/html/theory/index.html&param.CICURI=dummy:query_result&param.naturalLanguage=yes&param.annotations=no&param.topurl=http://helm.cs.unibo.it/helm">HELM
+ query engine</a> (enter <a
+ href="http://mowgli.cs.unibo.it/forward/58085/getpage?url=index.html&preprocess=true&param.processorURL=http%3A//mowgli.cs.unibo.it/forward/58080/&param.getterURL=http%3A//mowgli.cs.unibo.it/forward/58081/&param.proofcheckerURL=http%3A//mowgli.cs.unibo.it/forward/58084/&param.draw_graphURL=http%3A//mowgli.cs.unibo.it/forward/58083/&param.uri_set_queueURL=http%3A//mowgli.cs.unibo.it/forward/58082/&param.UNICODEvsSYMBOL=unicode&param.keys=d_c%2CC1%2CHC2%2CL&param.thkeys=T1%2CT2%2CL%2CE&param.embedkeys=d_c%2CTC1%2CHC2%2CL&param.doctype-public=-//W3C//DTD%20XHTML%201.0%20Transitional//EN&param.encoding=iso-8859-1&param.thencoding=iso-8859-1&param.media-type=text/html&param.thmedia-type=text/html&param.interfaceURL=http%3A//helm.cs.unibo.it/helm/html/cic/index.html&param.thinterfaceURL=http%3A//helm.cs.unibo.it/helm/html/theory/index.html&param.CICURI=dummy:query_result&param.naturalLanguage=yes&param.annotations=no&param.topurl=http://helm.cs.unibo.it/helm">here</a>
+ if you are behind a restrictive firewall), powered by MathQL-1.3, allows
+to issue both user-defined queries and the specific queries produced by the
+HELM query generator. <br>
+ </p>
+ </td>
+ </tr>
+
+ </tbody>
+</table>
+ <br>
+ <br>
+</body>
+</html>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <title>MathQL</title>
+
+
+ <meta http-equiv="content-type"
+ content="text/html; charset=ISO-8859-1">
+
+
+ <meta name="author" content="Ferruccio Guidi">
+
+
+ <meta name="description" content="MathQL Home Page">
+</head>
+ <body>
+
+<h1 align="center">MathQL-1</h1>
+
+<h2 align="center">A query language for RDF metadata</h2>
+
+<table cellpadding="10" cellspacing="2" border="0" width="95%"
+ bgcolor="#ffffff">
+ <tbody>
+ <tr>
+ <td valign="top" align="left">
+
+
+ <ul>
+ <li>Forward<br>
+ </li>
+
+
+
+ </ul>
+
+
+ <ul>
+ <li><a href="features.html">Features</a></li>
+
+
+ </ul>
+
+
+ <ul>
+ <li><a href="whatsnew.html">What's new</a></li>
+
+ </ul>
+
+ <ul>
+ <li><a href="documentation.html">Documentation</a></li>
+
+
+
+ </ul>
+
+
+ <ul>
+ <li><a href="implementation.html">Implementation</a><br>
+ </li>
+
+
+ </ul>
+
+
+ <ul>
+ <li><a href="authors.html">The authors</a><br>
+ </li>
+
+
+
+ </ul>
+
+
+ <ul>
+ <li><a href="links.html">Links</a><br>
+ </li>
+
+
+ </ul>
+ <br>
+ </td>
+ <td valign="top">
+
+
+ <div align="right"><b>Forward</b><br>
+ </div>
+ <br>
+ The MathQL proposal rises in the context of the <a
+ href="http://helm.cs.unibo.it/">HELM project</a>, which aims at the development
+of a suitable technology for the creation and maintenance of a virtual,
+distributed, hypertextual library of structured mathematical knowledge
+based on <a href="http://www.w3.org/XML/">XML</a> technology, through the
+ integration of the current proof assistants and logical frameworks with
+the most recent technologies for the development of Web applications and
+electronic publishing.<br>
+ <br>
+ The objective of the MathQL proposal is the development
+of a set of query languages enabling the retrieval of formalized mathematical
+ Web resources on the basis of content-aware requests. The first of these
+ languages, <b>MathQL-1</b>, is focused on querying an arbitrary
+ <a href="http://www.w3.org/RDF/">RDF</a> database because RDF is
+the <a href="http://www.w3.org/">W3C</a> standard for describing
+ Web resources at the general-purpose content level.<br>
+ <br>
+ As an RDF query language, MathQL-1 provides the main features
+ required by the RDF community while complying with the needs of HELM.
+ The peculiar aspects of this language concern the query results,
+which are highly structured and possess their own syntax, formally
+explained by a rigorous semantics.<br>
+ <br>
+ MathQL-1 is particularly helpful in distributed systems
+where query engines are implemented as stand-alone units, because
+in this situation the query results are exchanged between the system
+components as well as the queries, and thus both the queries and the query
+results need to be encoded in a clearly defined format.<br>
+ <br>
+ Other languages to be developed in the context of the MathQL proposal
+ will be suitable for queries about the semantic structure of mathematical
+ data: this will include content-based pattern-matching (MathQL-2) and
+possibly other forms of formal matching involving for instance isomorphism,
+unification and definitions expansion (MathQL-3).<br>
+ </td>
+ </tr>
+
+
+ </tbody>
+</table>
+ <br>
+ <br>
+
+<div align="center">This site is maintained by <a
+ href="mailto://fguidi@cs.unibo.it">Ferruccio Guidi</a>, last update: November
+13, 2003.<br>
+ </div>
+ <br>
+ <br>
+
+<div align="center"><a href="http://www.anybrowser.org/campaign"><img
+ src="http://www.cs.unibo.it/%7Efguidi/download/globe-trans.png"
+ alt="Any Browswr" width="147" height="42" border="0">
+ </a><a href="http://burnallgifs.org/"><img
+ src="http://www.cs.unibo.it/%7Efguidi/download/PNGnow2.png"
+ alt="PNG used here" width="119" height="42" border="0">
+ </a><br>
+ <br>
+ </div>
+ <br>
+ <br>
+</body>
+</html>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <title>MathQL</title>
+
+
+ <meta http-equiv="content-type"
+ content="text/html; charset=ISO-8859-1">
+
+ <meta name="author" content="Ferruccio Guidi">
+
+ <meta name="description" content="MathQL Home Page">
+</head>
+ <body>
+
+<h1 align="center">MathQL-1</h1>
+
+<h2 align="center">A query language for RDF metadata</h2>
+
+<table cellpadding="10" cellspacing="2" border="0" width="95%"
+ bgcolor="#ffffff">
+ <tbody>
+ <tr>
+ <td valign="top" align="left">
+
+ <ul>
+ <li><a href="index.html">Forward</a><br>
+ </li>
+
+
+ </ul>
+
+
+ <ul>
+ <li><a href="features.html">Features</a></li>
+
+
+ </ul>
+
+
+ <ul>
+ <li><a href="whatsnew.html">What's new</a></li>
+
+ </ul>
+
+ <ul>
+ <li><a href="documentation.html">Documentation</a></li>
+
+
+ </ul>
+
+
+ <ul>
+ <li><a href="implementation.html">Implementation</a><br>
+ </li>
+
+
+ </ul>
+
+
+ <ul>
+ <li><a href="authors.html">The authors</a><br>
+ </li>
+
+
+ </ul>
+
+
+ <ul>
+ <li>Links<br>
+ </li>
+
+
+ </ul>
+ <br>
+ </td>
+ <td valign="top">
+
+ <div align="right"><b>Links</b><br>
+ </div>
+
+ <ul>
+ <li><a href="http://helm.cs.unibo.it/">HELM</a> Project homepage,
+ <a href="http://mowgli.cs.unibo.it/">MOWGLI</a> Project homepage</li>
+
+ </ul>
+
+ <ul>
+ <li>W3C <a href="http://www.w3.org/XML/">XML</a> resources,
+ W3C <a href="http://www.w3c.org/RDF/">RDF</a> resources</li>
+
+ </ul>
+
+ <ul>
+ <li>Some RDF query languages having a homepage</li>
+
+ </ul>
+
+ <blockquote><a href="http://www.daml.org/">DAML+OIL</a> <a
+ href="http://guha.com/rdfdb/">rdfDB</a> <a
+ href="http://logicerror.com/RDFPath">RDFPath</a> <a
+ href="http://www.intellidimension.com/">RDFQL</a> <a
+ href="http://www.hpl.hp.com/semweb/rdql.htm">RDQL</a> <a
+ href="http://139.91.183.30:9090/RDF/">RQL</a> <a
+ href="http://www.dfki.uni-kl.de/ruleml/">RuleML</a> <a
+ href="http://triple.semanticweb.org/">TRIPLE</a> <a
+ href="http://swordfish.rdfweb.org/rdfquery/">SquishQL</a> <a
+ href="http://kr.cs.ait.ac.th/XDD/">XDD</a><br>
+ </blockquote>
+
+ <blockquote>The developers wishing to have their RDF query language
+ listed here may contact the <a href="authors.html">authors</a>.<br>
+ </blockquote>
+ </td>
+ </tr>
+
+ </tbody>
+</table>
+ <br>
+</body>
+</html>
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+ <title>MathQL</title>
+
+
+ <meta http-equiv="content-type"
+ content="text/html; charset=ISO-8859-1">
+
+ <meta name="author" content="Ferruccio Guidi">
+
+ <meta name="description" content="MathQL Home Page">
+</head>
+ <body>
+
+<h1 align="center">MathQL-1</h1>
+
+<h2 align="center">A query language for RDF metadata</h2>
+
+<table cellpadding="10" cellspacing="2" border="0" width="95%"
+ bgcolor="#ffffff">
+ <tbody>
+ <tr>
+ <td valign="top" align="left">
+
+
+ <ul>
+ <li><a href="index.html">Forward</a><br>
+ </li>
+
+
+ </ul>
+
+
+ <ul>
+ <li><a href="features.html">Features</a></li>
+
+ </ul>
+
+ <ul>
+ <li>What's new<br>
+ </li>
+
+
+ </ul>
+
+
+ <ul>
+ <li><a href="documentation.html">Documentation</a></li>
+
+
+ </ul>
+
+
+ <ul>
+ <li><a href="implementation.html">Implementation</a><br>
+ </li>
+
+
+ </ul>
+
+
+ <ul>
+ <li><a href="authors.html">The authors</a><br>
+ </li>
+
+
+ </ul>
+
+
+ <ul>
+ <li><a href="links.html">Links</a><br>
+ </li>
+
+
+ </ul>
+ <br>
+ </td>
+ <td valign="top">
+
+ <div align="right"><b>What's new</b><br>
+ <br>
+ </div>
+ This page reports the newly <a href="implementation.html">implemented</a>
+ features of MathQL-1 that are not included in the official <a
+ href="documentation.html">documentation</a> yet.<br>
+ <br>
+
+ <hr width="100%" size="2"><br>
+ <h3 align="center"><img
+ src="http://www.cs.unibo.it/%7Efguidi/download/bbb11.png" alt="New"
+ width="38" height="37" align="top">
+ MathQL-1 version 4 now under development ...</h3>
+We are now implementing the new unstable version of MathQL-1 (i.e. MathQL-1.4).
+The main goals of this release are:<br>
+ <ul>
+ <li>A clear distinction between the core language and the auxiliary
+functions, which should be part of an extensible library.<br>
+ </li>
+ </ul>
+ <ul>
+ <li>The elimination of the explicit casts between the <query>
+and <value> types in queries.<br>
+ </li>
+ </ul>
+ <ul>
+ <li>A tight connection with a query generator (i.e <a
+ href="implementation.html">HELM query generator</a>).<br>
+ </li>
+ </ul>
+ <hr width="100%" size="2">
+ <div align="center">
+ <h3>Changes and additions to MathQL-1 operators:</h3>
+ </div>
+
+ <ul>
+ <li>The <b>add</b> operator now accepts a syntax extension allowing
+ to specify more than one explicit attribute group.</li>
+
+ </ul>
+
+ <blockquote>The syntax now is:</blockquote>
+
+ <blockquote><query> := "add" [ "distr" ]? [ <groups> |
+<avar> ] "in" <query><br>
+ <groups> := <group> [ ";" <group> ]*<br>
+ <group> := <attribute> [ "," <attribute> ]*<br>
+ <attribute> := <value> "as" <path><br>
+ <br>
+ Examples:<br>
+ the query <b>add "1" as "a", "2" as "b" in subj "A"</b> gives the result
+ <b>"A" attr {"a"="1"; "b"="2"}</b> while<br>
+ the query <b>add "1" as "a"; "2" as "b" in subj "A"</b> gives the result
+ <b>"A" attr {"a"="1"}, {"b"="2"}</b>.<br>
+ </blockquote>
+
+ <ul>
+ <li>The new <b>align</b> operator takes an integer <i>i</i> (represented
+ as a string), a multiple string value <i>v</i> and returns the same <i>v</i>
+ where each string with length <i>n < i</i> is prefixed with <i>i - n</i>
+ spaces. The syntax of the add operator is:</li>
+
+ </ul>
+
+ <blockquote><value> := "align" <string> "in" <value><br>
+ <br>
+ This operators aligns strings containing numbers so that their alphabetic
+ order agrees with their numeric order.<br>
+ </blockquote>
+
+ <ul>
+ <li>The <b>intersect</b> operator now intersects the attribute
+ groups of the matching subject strings set-theoretically rather than making
+ their "Cartesian product". This semantics reduces the computational costs
+ and makes intersection the dual of union.</li>
+
+ </ul>
+
+ <ul>
+ <li>The <b>property</b> operator now accepts more than one <b>isfalse</b>
+ clause to increase the complexity of the constraint condition used to filter
+ the raw query results. This feature is exploited in the queries produced
+ by the <a href="implementation.html">HELM query generator</a>.</li>
+
+ </ul>
+ <br>
+
+ <hr width="100%" size="2">
+ <div align="center">
+ <h3>The PostgreSQL database map:</h3>
+ </div>
+ The <b>PostgreSQL database map</b> is a file describing how the MathQL-1
+ interpreter must interact with the underlying PostgreSQL database, when
+it is run in Postgres mode. Currently this file contains the following information:<br>
+
+ <ul>
+ <li>the <i>database connection string</i> to be used when the interpreter
+ opens a connection with the database;</li>
+
+ </ul>
+
+ <ul>
+ <li>the <i>map</i> describing the correspondence between the metadata
+ access paths used by the <i>property</i> operator and the fields of the
+database tables.</li>
+
+ </ul>
+ The format of the file is textual and line oriented, but a corresponding
+ XML syntax will be provided soon.<br>
+ The first line must contain the database connection string and the subsequent
+ lines contain the map with the following syntax:<br>
+
+ <ul>
+ <li>blank lines: ignored (used for separation);</li>
+
+ </ul>
+
+ <ul>
+ <li>lines starting with a # followed by a space: ignored (used
+for comments);<br>
+ </li>
+
+ </ul>
+
+ <ul>
+ <li><table_name> <field_name> "<-"
+ [ <path_component> ]*<br>
+ </li>
+
+ </ul>
+
+ <blockquote>the information about the metadata denoted by the given
+ path is found in the given field of the given table in the database. For
+example the line:<br>
+ <br>
+ refobj h_occurrence <- refObj h:occurrence<br>
+ <br>
+ tells that the metadata denoted by the path <b>/"refObj"/"h:occurrence"</b>
+ is found in the field "h_occurrence" of the table "refobj" in the database,
+ while:<br>
+ <br>
+ refobj source <-<br>
+ <br>
+ tells that the metadata denoted by the path <b>/</b> is found in the field
+ "source" of the table "refobj" in the database;<br>
+ </blockquote>
+
+ <ul>
+ <li><table_name> <field_name> "<+"
+ [ <path_component> ]*<br>
+ </li>
+
+ </ul>
+
+ <blockquote>same as the previous but defines a default table and field
+ for the given path. This is used to force the interpreter to query a particular
+ table when the information denoted by a path can be found in more than one
+ table and field. For example:<br>
+ <br>
+ objectname source <+<br>
+ refobj source <-<br>
+ refrel source
+<-<br>
+ refsort source <-<br>
+ <br>
+ tells that the metadata denoted by the path <b>/</b> is found in the "source"
+ field of the "objectname", "refobj", "refrel" and "refsort" tables, and
+that the first choice is preferred;<br>
+ </blockquote>
+
+ <ul>
+ <li><table_name> "<-" [ <path_component> ]*</li>
+
+ </ul>
+
+ <blockquote>the given path denotes a structured metadata whose components
+ are found in the fields of the given table. For example:<br>
+ <br>
+ refobj <- refObj<br>
+ <br>
+ tells that the path <b>/"refObj"</b> denotes a structured metadata whose
+ components are found in the fields of the table "refobj"; <br>
+ </blockquote>
+
+ <ul>
+ <li><table_name> "<+" [ <path_component> ]*</li>
+
+ </ul>
+
+ <blockquote>same as the previous but tells that this is a default correspondence;
+ <br>
+ </blockquote>
+
+ <ul>
+ <li><virtual_table_name> "->" <concrete_table_name></li>
+
+ </ul>
+
+ <blockquote>defines a correspondence between a virtual table name an
+ a concrete table name. All the <table_name> entries represent virtual
+ table names that are mapped to concrete table names using the identity function
+ unless a particular mapping is defined for them using the above construction.
+ This mechanism allows to define several set of metadata on the same database
+ table as in:<br>
+ <br>
+ refobj source
+ <-<br>
+ refobj h_occurrence <-
+ refObj h:occurrence<br>
+ backpointer source
+ <- backPointer h:occurrence<br>
+ backpointer h_occurrence <-<br>
+ backpointer
+ -> refobj<br>
+ </blockquote>
+
+ <blockquote>which defines four path accessing two virtual tables ("refobj"
+ and "backpointer") and then maps these tables in a single concrete table;<br>
+ </blockquote>
+
+ <ul>
+ <li>"->" <br>
+ </li>
+
+ </ul>
+
+ <blockquote>a line like this must end the map file. <br>
+ </blockquote>
+ Here you can find the <a
+ href="http://www.cs.unibo.it/cgi-bin/cvsweb/helm/mathql_db_map.txt">current
+ version of PostgreSQL database map for HELM</a>.<br>
+ <br>
+ <b>How does the interpreter use the map?</b> The map file is read
+during the interpreter initialization process from the file pointed by the
+MATHQL_DB_MAP environment variable and is used during the execution of each
+ <i>property</i> operation in the issued queries.When executing a <i>property</i>
+operation, the interpreter uses the map to find the smallest set of database
+tables containing the information required by the given access paths and then
+queries these tables to obtain the wanted information. <br>
+ </td>
+ </tr>
+
+ </tbody>
+</table>
+ <br>
+ <br>
+</body>
+</html>
--- /dev/null
+PACKAGE = mathql
+
+PREDICATES =
+
+INTERFACE_FILES =
+
+IMPLEMENTATION_FILES = mathQL.ml
+
+EXTRA_OBJECTS_TO_INSTALL = mathQL.ml mathQL.cmi
+
+EXTRA_OBJECTS_TO_CLEAN =
+
+include ../Makefile.common
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://www.cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+(* $Id$ *)
+
+(* output data structures ***************************************************)
+
+type path = string list (* the name of an attribute *)
+
+type value = string list (* the value of an attribute *)
+
+type attribute = path * value (* an attribute *)
+
+type attribute_group = attribute list (* a group of attributes *)
+
+type attribute_set = attribute_group list (* the attributes of an URI *)
+
+type resource = string * attribute_set (* an attributed URI *)
+
+type resource_set = resource list (* the query result *)
+
+type result = resource_set
+
+
+(* input data structures ****************************************************)
+
+type svar = string (* the name of a variable for a resource set *)
+
+type avar = string (* the name of a variable for a resource *)
+
+type vvar = string (* the name of a variable for an attribute value *)
+
+type inverse = bool
+
+type refine = RefineExact
+ | RefineSub
+ | RefineSuper
+
+type main = path
+
+type pattern = bool
+
+type exp = path * (path option)
+
+type exp_list = exp list
+
+type allbut = bool
+
+type xml = bool
+
+type source = bool
+
+type bin = BinFJoin (* full union - with attr handling *)
+ | BinFMeet (* full intersection - with attr handling *)
+ | BinFDiff (* full difference - with attr handling *)
+
+type gen = GenFJoin (* full union - with attr handling *)
+ | GenFMeet (* full intersection - with attr handling *)
+
+type test = Xor
+ | Or
+ | And
+ | Sub
+ | Meet
+ | Eq
+ | Le
+ | Lt
+
+type query = Empty
+ | SVar of svar
+ | AVar of avar
+ | Subj of msval
+ | Property of inverse * refine * path *
+ main * istrue * isfalse list * exp_list *
+ pattern * msval
+ | Select of avar * query * msval
+ | Bin of bin * query * query
+ | LetSVar of svar * query * query
+ | LetVVar of vvar * msval * query
+ | For of gen * avar * query * query
+ | Add of bool * groups * query
+ | If of msval * query * query
+ | Log of xml * source * query
+ | StatQuery of query
+ | Keep of allbut * path list * query
+
+and msval = False
+ | True
+ | Not of msval
+ | Ex of avar list * msval
+ | Test of test * msval * msval
+ | Const of string
+ | Set of msval list
+ | Proj of path option * query
+ | Dot of avar * path
+ | VVar of vvar
+ | StatVal of msval
+ | Count of msval
+ | Align of string * msval
+
+and groups = Attr of (path * msval) list list
+ | From of avar
+
+and con = pattern * path * msval
+
+and istrue = con list
+
+and isfalse = con list
--- /dev/null
+objectName source <+
+objectName value <- objectName
+refObj <- refObj
+refObj source <-
+refObj h_occurrence <- refObj h:occurrence
+refObj h_position <- refObj h:position
+refObj h_depth <- refObj h:depth
+refRel <- refRel
+refRel source <-
+refRel h_position <- refRel h:position
+refRel h_depth <- refRel h:depth
+refSort <- refSort
+refSort source <-
+refSort h_sort <- refSort h:sort
+refSort h_position <- refSort h:position
+refSort h_depth <- refSort h:depth
+backPointer <- backPointer
+backPointer source <- backPointer h:occurrence
+backPointer h_occurrence <-
+backPointer h_position <- backPointer h:position
+backPointer h_depth <- backPointer h:depth
+no_inconcl_aux source <-
+no_inconcl_aux no <- no_inconcl
+
+backPointer -> refObj
+ ->
--- /dev/null
+mQGUtil.cmi: mQGTypes.cmo
+mQueryGenerator.cmi: mQGTypes.cmo
+cGMatchConclusion.cmi: mQGTypes.cmo
+cGSearchPattern.cmi: mQGTypes.cmo
+cGLocateInductive.cmi: mQGTypes.cmo
+mQGUtil.cmo: mQGTypes.cmo mQGUtil.cmi
+mQGUtil.cmx: mQGTypes.cmx mQGUtil.cmi
+mQueryGenerator.cmo: mQGUtil.cmi mQGTypes.cmo mQueryGenerator.cmi
+mQueryGenerator.cmx: mQGUtil.cmx mQGTypes.cmx mQueryGenerator.cmi
+cGMatchConclusion.cmo: mQGTypes.cmo cGMatchConclusion.cmi
+cGMatchConclusion.cmx: mQGTypes.cmx cGMatchConclusion.cmi
+cGSearchPattern.cmo: mQGUtil.cmi mQGTypes.cmo cGSearchPattern.cmi
+cGSearchPattern.cmx: mQGUtil.cmx mQGTypes.cmx cGSearchPattern.cmi
+cGLocateInductive.cmo: mQGTypes.cmo cGLocateInductive.cmi
+cGLocateInductive.cmx: mQGTypes.cmx cGLocateInductive.cmi
--- /dev/null
+PACKAGE = mathql_generator
+
+PREDICATES =
+
+INTERFACE_FILES = mQGUtil.mli mQueryGenerator.mli \
+ cGMatchConclusion.mli cGSearchPattern.mli \
+ cGLocateInductive.mli
+
+IMPLEMENTATION_FILES = mQGTypes.ml $(INTERFACE_FILES:%.mli=%.ml)
+
+EXTRA_OBJECTS_TO_INSTALL = mQGTypes.ml mQGTypes.cmi
+
+EXTRA_OBJECTS_TO_CLEAN =
+
+include ../Makefile.common
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+(* $Id$ *)
+
+exception NotAnInductiveDefinition
+
+let get_constraints = function
+ | Cic.MutInd (uri, t, _) ->
+ let uri = UriManager.string_of_uriref (uri, [t]) in
+ let constr_obj =
+ [(`InHypothesis, uri); (`MainHypothesis (Some 0), uri)]
+ in
+ let constr_rel = [`MainConclusion None] in
+ let constr_sort = [(`MainHypothesis (Some 1), MQGTypes.Prop)] in
+ (constr_obj, constr_rel, constr_sort)
+ | _ -> raise NotAnInductiveDefinition
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+val get_constraints : Cic.term -> MQGTypes.must_restrictions
+
+exception NotAnInductiveDefinition
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+(* $Id$ *)
+
+module T = MQGTypes
+
+let text_of_entries out entries =
+ out "(** MatchConclusion: results of the term inspection **)\n";
+ let text_of_entry (u, b, v) =
+ out (string_of_int v ^ " ");
+ out (if b then "$MC " else "$IC ");
+ out (u ^ "\n")
+ in List.iter text_of_entry entries
+
+let sort_entries entries =
+ let comparator (_, _, v1) (_, _, v2) = compare v1 v2 in
+ List.fast_sort comparator entries
+
+let levels_of_term metasenv context term =
+ let module TC = CicTypeChecker in
+ let module Red = CicReduction in
+ let degree t =
+ let rec degree_aux = function
+ | Cic.Sort _ -> 1
+ | Cic.Cast (u, _) -> degree_aux u
+ | Cic.Prod (_, _, t) -> degree_aux t
+ | _ -> 2
+ in
+ let u,_ = TC.type_of_aux' metasenv context t CicUniv.empty_ugraph in
+ degree_aux (Red.whd context u)
+ in
+ let entry_eq (s1, b1, v1) (s2, b2, v2) =
+ s1 = s2 && b1 = b2
+ in
+ let rec entry_in e = function
+ | [] -> [e]
+ | head :: tail ->
+ head :: if entry_eq head e then tail else entry_in e tail
+ in
+ let inspect_uri main l uri tc v term =
+ let d = degree term in
+ entry_in (UriManager.string_of_uriref (uri, tc), main, 2 * v + d - 1) l
+ in
+ let rec inspect_term main l v term = match term with
+ Cic.Rel _ -> l
+ | Cic.Meta _ -> l
+ | Cic.Sort _ -> l
+ | Cic.Implicit _ -> l
+ | Cic.Var (u,exp_named_subst) ->
+ inspect_exp_named_subst l (succ v) exp_named_subst
+(*
+ let l' = inspect_uri main l u [] v term in
+ inspect_exp_named_subst l' (succ v) exp_named_subst
+*)
+ | Cic.Const (u,exp_named_subst) ->
+ let l' = inspect_uri main l u [] v term in
+ inspect_exp_named_subst l' (succ v) exp_named_subst
+ | Cic.MutInd (u, t, exp_named_subst) ->
+ let l' = inspect_uri main l u [t] v term in
+ inspect_exp_named_subst l' (succ v) exp_named_subst
+ | Cic.MutConstruct (u, t, c, exp_named_subst) ->
+ let l' = inspect_uri main l u [t; c] v term in
+ inspect_exp_named_subst l' (succ v) exp_named_subst
+ | Cic.Cast (uu, _) ->
+ inspect_term main l v uu
+ | Cic.Prod (_, uu, tt) ->
+ let luu = inspect_term false l (succ v) uu in
+ inspect_term main luu (succ v) tt
+ | Cic.Lambda (_, uu, tt) ->
+ let luu = inspect_term false l (succ v) uu in
+ inspect_term false luu (succ v) tt
+ | Cic.LetIn (_, uu, tt) ->
+ let luu = inspect_term false l (succ v) uu in
+ inspect_term false luu (succ v) tt
+ | Cic.Appl m -> inspect_list main l true v m
+ | Cic.MutCase (u, t, tt, uu, m) ->
+ let lu = inspect_uri main l u [t] (succ v) term in
+ let ltt = inspect_term false lu (succ v) tt in
+ let luu = inspect_term false ltt (succ v) uu in
+ inspect_list main luu false (succ v) m
+ | Cic.Fix (_, m) -> inspect_ind l (succ v) m
+ | Cic.CoFix (_, m) -> inspect_coind l (succ v) m
+ and inspect_list main l head v = function
+ | [] -> l
+ | tt :: m ->
+ let ltt = inspect_term main l (if head then v else v + 1) tt in
+ inspect_list false ltt false v m
+ and inspect_exp_named_subst l v = function
+ [] -> l
+ | (_,t) :: tl ->
+ let l' = inspect_term false l v t in
+ inspect_exp_named_subst l' v tl
+ and inspect_ind l v = function
+ | [] -> l
+ | (_, _, tt, uu) :: m ->
+ let ltt = inspect_term false l v tt in
+ let luu = inspect_term false ltt v uu in
+ inspect_ind luu v m
+ and inspect_coind l v = function
+ | [] -> l
+ | (_, tt, uu) :: m ->
+ let ltt = inspect_term false l v tt in
+ let luu = inspect_term false ltt v uu in
+ inspect_coind luu v m
+ in
+ let rec inspect_backbone = function
+ | Cic.Cast (uu, _) -> inspect_backbone uu
+ | Cic.Prod (_, _, tt) -> inspect_backbone tt
+ | Cic.LetIn (_, uu, tt) -> inspect_backbone tt
+ | t -> inspect_term true [] 0 t
+ in
+ inspect_backbone term
+
+let get_constraints e c t =
+ let can = sort_entries (levels_of_term e c t) in (* can restrictions *)
+ text_of_entries prerr_string can; flush stderr; (* logging *)
+ let rest_of (u, b, _) =
+ let p = if b then `MainConclusion None else `InConclusion in (p, u)
+ in
+ let rec split vp = function
+ | [], ((_, _, v) as hd) :: tl -> split v ([rest_of hd], tl)
+ | prev, ((_, _, ve) as hd) :: tl when vp = ve ->
+ split vp (rest_of hd :: prev, tl)
+ | p, l -> p, l
+ in
+ let rec mk_musts prev acc = function
+ | [] -> prev, acc
+ | l ->
+ let slice, next = split 0 ([], l) in
+ let acc = acc @ slice in
+ mk_musts (prev @ [acc]) acc next
+ in
+ mk_musts [] [] can
+
+let universe = [T.MainConclusion; T.InConclusion]
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+val get_constraints: Cic.metasenv -> Cic.context -> Cic.term ->
+ MQGTypes.r_obj list list *
+ MQGTypes.r_obj list
+
+val universe : MQGTypes.universe
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(******************************************************************************)
+(* *)
+(* PROJECT HELM *)
+(* *)
+(* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
+(* 02/12/2002 *)
+(* *)
+(* Missing description *)
+(* *)
+(******************************************************************************)
+
+(* $Id$ *)
+
+module T = MQGTypes
+module U = MQGUtil
+
+type classification =
+ Backbone of int
+ | Branch of int
+ | InConclusion
+ | InHypothesis
+;;
+
+let soften_classification =
+ function
+ Backbone _ -> InConclusion
+ | Branch _ -> InHypothesis
+ | k -> k
+;;
+
+let (!!) =
+ function
+ Backbone n -> `MainConclusion (Some n)
+ | Branch n -> `MainHypothesis (Some n)
+ | _ -> assert false
+;;
+
+let (!!!) =
+ function
+ Backbone n -> `MainConclusion (Some n)
+ | Branch n -> `MainHypothesis (Some n)
+ | InConclusion -> `InConclusion
+ | InHypothesis -> `InHypothesis
+;;
+
+
+let (@@) (l1,l2,l3) (l1',l2',l3') =
+ let merge l1 l2 =
+ List.fold_left (fun i t -> if List.mem t l2 then i else t::i) l2 l1
+ in
+ merge l1 l1', merge l2 l2', merge l3 l3'
+;;
+
+let get_constraints term =
+ let module U = UriManager in
+ let module C = Cic in
+ let rec process_type_aux kind =
+ function
+ C.Var (uri,expl_named_subst) ->
+ (* andrea: this is a bug: variable are not indexedin the db
+ ([!!!kind, UriManager.string_of_uri uri],[],[]) @@ *)
+ (process_type_aux_expl_named_subst kind expl_named_subst)
+ | C.Rel _ ->
+ (match kind with
+ | InConclusion
+ | InHypothesis -> [],[],[]
+ | _ -> [],[!!kind],[])
+ | C.Sort s ->
+ (match kind with
+ Backbone _
+ | Branch _ ->
+ let s' =
+ match s with
+ Cic.Prop -> T.Prop
+ | Cic.Set -> T.Set
+ | Cic.Type _ -> T.Type (* TASSI: ?? *)
+ | Cic.CProp -> T.CProp
+ in
+ [],[],[!!kind,s']
+ | _ -> [],[],[])
+ | C.Meta _ -> [],[],[] (* ???? To be understood *)
+ | C.Implicit _ -> assert false
+ | C.Cast (te,_) ->
+ (* type ignored *)
+ process_type_aux kind te
+ | C.Prod (_,sou,ta) ->
+ let (source_kind,target_kind) =
+ match kind with
+ Backbone n -> (Branch 0, Backbone (n+1))
+ | Branch n -> (InHypothesis, Branch (n+1))
+ | k -> (k,k)
+ in
+ process_type_aux source_kind sou @@
+ process_type_aux target_kind ta
+ | C.Lambda (_,sou,ta) ->
+ let kind' = soften_classification kind in
+ process_type_aux kind' sou @@
+ process_type_aux kind' ta
+ | C.LetIn (_,te,ta)->
+ let kind' = soften_classification kind in
+ process_type_aux kind' te @@
+ process_type_aux kind ta
+ | C.Appl (he::tl) ->
+ let kind' = soften_classification kind in
+ process_type_aux kind he @@
+ List.fold_left (fun i t -> i @@ process_type_aux kind' t) ([],[],[]) tl
+ | C.Appl _ -> assert false
+ | C.Const (uri,_) ->
+ [!!!kind, UriManager.string_of_uri uri],[],[]
+ | C.MutInd (uri,typeno,expl_named_subst) ->
+ ([!!!kind, U.string_of_uri uri ^ "#xpointer(1/" ^
+ string_of_int (typeno + 1) ^ ")"],[],[]) @@
+ (process_type_aux_expl_named_subst kind expl_named_subst)
+ | C.MutConstruct (uri,typeno,consno,expl_named_subst) ->
+ ([!!!kind, U.string_of_uri uri ^ "#xpointer(1/" ^
+ string_of_int (typeno + 1) ^ "/" ^ string_of_int consno ^ ")"],[],[])
+ @@ (process_type_aux_expl_named_subst kind expl_named_subst)
+ | C.MutCase (_,_,_,term,patterns) ->
+ (* outtype ignored *)
+ let kind' = soften_classification kind in
+ process_type_aux kind' term @@
+ List.fold_left (fun i t -> i @@ process_type_aux kind' t)
+ ([],[],[]) patterns
+ | C.Fix (_,funs) ->
+ let kind' = soften_classification kind in
+ List.fold_left
+ (fun i (_,_,bo,ty) ->
+ i @@
+ process_type_aux kind' bo @@
+ process_type_aux kind' ty
+ ) ([],[],[]) funs
+ | C.CoFix (_,funs) ->
+ let kind' = soften_classification kind in
+ List.fold_left
+ (fun i (_,bo,ty) ->
+ i @@
+ process_type_aux kind' bo @@
+ process_type_aux kind' ty
+ ) ([],[],[]) funs
+ and process_type_aux_expl_named_subst kind =
+ List.fold_left
+ (fun i (_,t) -> i @@ (process_type_aux (soften_classification kind) t))
+ ([],[],[])
+in
+ let obj_constraints,rel_constraints,sort_constraints =
+ process_type_aux (Backbone 0) (CicMiniReduction.letin_nf term)
+ in
+ (obj_constraints,rel_constraints,sort_constraints)
+;;
+
+(*CSC: Debugging only *)
+(*
+let get_constraints term =
+ let res = get_constraints term in
+ let (objs,rels,sorts) = res in
+ let text_of_pos p =
+ U.text_of_position p ^ " " ^ U.text_of_depth p "NULL"
+ in
+ prerr_endline "Constraints on objs:" ;
+ List.iter
+ (function (p, u) -> prerr_endline (text_of_pos p ^ " " ^ u)) objs ;
+ prerr_endline "Constraints on Rels:" ;
+ List.iter (function p -> prerr_endline (text_of_pos (p:>T.full_position))) rels ;
+ prerr_endline "Constraints on Sorts:" ;
+ List.iter
+ (function (p, s) -> prerr_endline (text_of_pos (p:>T.full_position) ^ " " ^ U.text_of_sort s)
+ ) sorts ;
+ res
+;; *)
+
+let universe =
+ [T.MainHypothesis; T.InHypothesis; T.MainConclusion; T.InConclusion]
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(******************************************************************************)
+(* *)
+(* PROJECT HELM *)
+(* *)
+(* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
+(* 02/12/2002 *)
+(* *)
+(* Missing description *)
+(* *)
+(******************************************************************************)
+
+val get_constraints : Cic.term -> MQGTypes.must_restrictions
+
+val universe : MQGTypes.universe
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTORS: Ferruccio Guidi <fguidi@cs.unibo.it>
+ * Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>
+ *)
+
+(* $Id$ *)
+
+(* low level types *********************************************************)
+
+type uri = string
+type position = MainHypothesis
+ | InHypothesis
+ | MainConclusion
+ | InConclusion
+ | InBody
+type depth = int
+type sort = Set
+ | Prop
+ | Type
+ | CProp
+
+type spec = MustObj of uri list * position list * depth list
+ | MustSort of sort list * position list * depth list
+ | MustRel of position list * depth list
+ | OnlyObj of uri list * position list * depth list
+ | OnlySort of sort list * position list * depth list
+ | OnlyRel of position list * depth list
+ | Universe of position list
+
+(* high-level types ********************************************************)
+
+type optional_depth = int option
+
+type full_position = [ `MainHypothesis of optional_depth
+ | `MainConclusion of optional_depth
+ | `InHypothesis
+ | `InConclusion
+ | `InBody
+ ]
+
+type main_position = [ `MainHypothesis of optional_depth
+ | `MainConclusion of optional_depth
+ ]
+
+type r_obj = full_position * uri
+type r_sort = main_position * sort
+type r_rel = main_position
+
+type must_restrictions = (r_obj list * r_rel list * r_sort list)
+type only_restrictions =
+ (r_obj list option * r_rel list option * r_sort list option)
+
+type universe = position list
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+(* $Id$ *)
+
+module T = MQGTypes
+
+(* low level functions *****************************************************)
+
+let string_of_position p =
+ let ns = "http://www.cs.unibo.it/helm/schemas/schema-helm#" in
+ match p with
+ | T.MainHypothesis -> ns ^ "MainHypothesis"
+ | T.InHypothesis -> ns ^ "InHypothesis"
+ | T.MainConclusion -> ns ^ "MainConclusion"
+ | T.InConclusion -> ns ^ "InConclusion"
+ | T.InBody -> ns ^ "InBody"
+
+let string_of_sort = function
+ | T.Set -> "Set"
+ | T.Prop -> "Prop"
+ | T.Type -> "Type"
+ | T.CProp -> "CProp"
+
+let string_of_depth = string_of_int
+
+let mathql_of_position = function
+ | T.MainHypothesis -> "$MH"
+ | T.InHypothesis -> "$IH"
+ | T.MainConclusion -> "$MC"
+ | T.InConclusion -> "$IC"
+ | T.InBody -> "$IB"
+
+let mathql_of_sort = function
+ | T.Set -> "$SET"
+ | T.Prop -> "$PROP"
+ | T.Type -> "$TYPE"
+ | T.CProp -> "$CPROP"
+
+let mathql_of_depth = string_of_int
+
+let mathql_of_uri u = u
+
+let mathql_of_specs out l =
+ let rec iter f = function
+ | [] -> ()
+ | [s] -> out "\""; out (f s); out "\""
+ | s :: tail -> out "\""; out (f s); out "\", "; iter f tail
+ in
+ let txt_uri l = out "{"; iter mathql_of_uri l; out "} " in
+ let txt_pos l = out "{"; iter mathql_of_position l; out "} " in
+ let txt_sort l = out "{"; iter mathql_of_sort l; out "} " in
+ let txt_depth l = out "{"; iter mathql_of_depth l; out "} " in
+ let txt_spec = function
+ | T.MustObj (u, p, d) -> out "mustobj "; txt_uri u; txt_pos p; txt_depth d; out "\n"
+ | T.MustSort (s, p, d) -> out "mustsort "; txt_sort s; txt_pos p; txt_depth d; out "\n"
+ | T.MustRel ( p, d) -> out "mustrel "; txt_pos p; txt_depth d; out "\n"
+ | T.OnlyObj (u, p, d) -> out "onlyobj "; txt_uri u; txt_pos p; txt_depth d; out "\n"
+ | T.OnlySort (s, p, d) -> out "onlysort "; txt_sort s; txt_pos p; txt_depth d; out "\n"
+ | T.OnlyRel ( p, d) -> out "onlyrel "; txt_pos p; txt_depth d; out "\n"
+ | T.Universe ( p ) -> out "universe "; txt_pos p; out "\n"
+ in
+ List.iter txt_spec l
+
+let position_of_mathql = function
+ | "$MH" -> T.MainHypothesis
+ | "$IH" -> T.InHypothesis
+ | "$MC" -> T.MainConclusion
+ | "$IC" -> T.InConclusion
+ | "$IB" -> T.InBody
+ | _ -> raise Parsing.Parse_error
+
+let sort_of_mathql = function
+ | "$SET" -> T.Set
+ | "$PROP" -> T.Prop
+ | "$TYPE" -> T.Type
+ | "$CPROP" -> T.CProp
+ | _ -> raise Parsing.Parse_error
+
+let depth_of_mathql s =
+ try
+ let d = int_of_string s in
+ if d < 0 then raise (Failure "") else d
+ with Failure _ -> raise Parsing.Parse_error
+
+let uri_of_mathql s = s
+
+(* high level functions ****************************************************)
+
+let text_of_position = function
+ | `MainHypothesis _ -> "MainHypothesis"
+ | `MainConclusion _ -> "MainConclusion"
+ | `InHypothesis -> "InHypothesis"
+ | `InConclusion -> "InConclusion"
+ | `InBody -> "InBody"
+
+let text_of_depth pos no_depth_text = match pos with
+ | `MainHypothesis (Some d)
+ | `MainConclusion (Some d) -> string_of_int d
+ | _ -> no_depth_text
+
+let text_of_sort = function
+ | T.Set -> "Set"
+ | T.Prop -> "Prop"
+ | T.Type -> "Type"
+ | T.CProp -> "CProp"
+
+let is_main_position = function
+ | `MainHypothesis _
+ | `MainConclusion _ -> true
+ | _ -> false
+
+let is_conclusion = function
+ | `MainConclusion _
+ | `InConclusion -> true
+ | _ -> false
+
+let set_full_position pos depth = match pos with
+ | `MainHypothesis _ -> `MainHypothesis depth
+ | `MainConclusion _ -> `MainConclusion depth
+ | _ -> pos
+
+let set_main_position pos depth = match pos with
+ | `MainHypothesis _ -> `MainHypothesis depth
+ | `MainConclusion _ -> `MainConclusion depth
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+(* low level functions *****************************************************)
+
+(* these functions give the string representation used in the db ----------*)
+
+val string_of_position : MQGTypes.position -> string
+val string_of_depth : MQGTypes.depth -> string
+val string_of_sort : MQGTypes.sort -> string
+
+(* these functions give the string representation used in MathQL ----------*)
+
+val mathql_of_position : MQGTypes.position -> string
+val mathql_of_depth : MQGTypes.depth -> string
+val mathql_of_uri : MQGTypes.uri -> string
+val mathql_of_sort : MQGTypes.sort -> string
+
+val mathql_of_specs : (string -> unit) -> MQGTypes.spec list -> unit
+
+val position_of_mathql : string -> MQGTypes.position
+val depth_of_mathql : string -> MQGTypes.depth
+val uri_of_mathql : string -> MQGTypes.uri
+val sort_of_mathql : string -> MQGTypes.sort
+
+(* high level functions ****************************************************)
+
+(* these functions give the textual representation used by umans ----------*)
+
+val text_of_position : MQGTypes.full_position -> string
+val text_of_depth : MQGTypes.full_position -> string -> string
+val text_of_sort : MQGTypes.sort -> string
+
+(* these functions classify the positions ---------------------------------*)
+
+val is_main_position : MQGTypes.full_position -> bool
+val is_conclusion : MQGTypes.full_position -> bool
+
+(* these function apply changes to positions ------------------------------*)
+
+val set_full_position : MQGTypes.full_position -> MQGTypes.optional_depth ->
+ MQGTypes.full_position
+val set_main_position : MQGTypes.main_position -> MQGTypes.optional_depth ->
+ MQGTypes.main_position
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+(* $Id$ *)
+
+module M = MathQL
+module T = MQGTypes
+module U = MQGUtil
+
+(* low level functions *****************************************************)
+
+let locate s =
+ let query =
+ M.Property (true,M.RefineExact,["objectName"],[],[],[],[],false,(M.Const s) )
+ in query
+
+let unreferred target_pattern source_pattern =
+ let query =
+ M.Bin (M.BinFDiff,
+ (
+ M.Property(false,M.RefineExact,[],[],[],[],[],true,(M.Const target_pattern))
+ ), (
+ M.Property(false,M.RefineExact,["refObj"],["h:occurrence"],[],[],[],true,(M.Const source_pattern))
+
+ ))
+ in query
+
+let compose cl =
+ let letin = ref [] in
+ let must = ref [] in
+ let onlyobj = ref [] in
+ let onlysort = ref [] in
+ let onlyrel = ref [] in
+ let only = ref true in
+ let univ = ref [] in
+ let set_val = function
+ | [s] -> M.Const s
+ | l ->
+ let msval = M.Set (List.map (fun s -> M.Const s) l) in
+ if ! only then begin
+ let vvar = "val" ^ string_of_int (List.length ! letin) in
+ letin := (vvar, msval) :: ! letin;
+ M.VVar vvar
+ end else msval
+ in
+ let cons o (r, s, p, d) =
+ let con p = function
+ | [] -> []
+ | l -> [(false, [p], set_val l)]
+ in
+ only := o;
+ con "h:occurrence" r @
+ con "h:sort" (List.map U.string_of_sort s) @
+ con "h:position" (List.map U.string_of_position p) @
+ con "h:depth" (List.map U.string_of_depth d)
+ in
+ let property_must n c =
+ M.Property(true,M.RefineExact,[n],[],(cons false c),[],[],false,(M.Const ""))
+ in
+ let property_only n cl =
+ let rec build = function
+ | [] -> []
+ | c :: tl ->
+ let r = (cons true) c in
+ if r = [] then build tl else r :: build tl
+ in
+ let cll = build cl in
+ M.Property(false,M.RefineExact,[n],[],!univ,cll,[],false,(M.Proj(None,(M.AVar "obj"))))
+ in
+ let rec aux = function
+ | [] -> ()
+ | T.Universe l :: tail ->
+ only := true;
+ let l = List.map U.string_of_position l in
+ univ := [(false, ["h:position"], set_val l)]; aux tail
+ | T.MustObj(r,p,d) :: tail ->
+ must := property_must "refObj" (r, [], p, d) :: ! must; aux tail
+ | T.MustSort(s,p,d) :: tail ->
+ must := property_must "refSort" ([], s, p, d) :: ! must; aux tail
+ | T.MustRel(p,d) :: tail ->
+ must := property_must "refRel" ([], [], p, d) :: ! must; aux tail
+ | T.OnlyObj(r,p,d) :: tail ->
+ onlyobj := (r, [], p, d) :: ! onlyobj; aux tail
+ | T.OnlySort(s,p,d) :: tail ->
+ onlysort := ([], s, p, d) :: ! onlysort; aux tail
+ | T.OnlyRel(p,d) :: tail ->
+ onlyrel := ([], [], p, d) :: ! onlyrel; aux tail
+ in
+ let rec iter f g = function
+ | [] -> raise (Failure "MQueryGenerator.iter")
+ | [head] -> (f head)
+ | head :: tail -> let t = (iter f g tail) in g (f head) t
+ in
+ (* prerr_endline "(** Compose: received constraints **)";
+ U.mathql_of_specs prerr_string cl; flush stderr; *)
+ aux cl;
+ let must_query =
+ if ! must = [] then
+ M.Property(false,M.RefineExact,[],[],[],[],[],true,(M.Const ".*"))
+ else
+ iter (fun x -> x) (fun x y -> M.Bin(M.BinFMeet,x,y)) ! must
+ in
+ let onlyobj_val = M.Not (M.Proj(None,(property_only "refObj" ! onlyobj))) in
+ let onlysort_val = M.Not (M.Proj(None,(property_only "refSort" ! onlysort))) in
+ let onlyrel_val = M.Not (M.Proj(None,(property_only "refRel" ! onlyrel))) in
+ let select_query x =
+ match ! onlyobj, ! onlysort, ! onlyrel with
+ | [], [], [] -> x
+ | _, [], [] -> M.Select("obj",x,onlyobj_val)
+ | [], _, [] -> M.Select("obj",x,onlysort_val)
+ | [], [], _ -> M.Select("obj",x,onlyrel_val)
+ | _, _, [] -> M.Select("obj",x,(M.Test(M.And,onlyobj_val,onlysort_val)))
+ | _, [], _ -> M.Select("obj",x,(M.Test(M.And,onlyobj_val,onlyrel_val)))
+ | [], _, _ -> M.Select("obj",x,(M.Test(M.And,onlysort_val,onlyrel_val)))
+ | _, _, _ -> M.Select("obj",x,(M.Test(M.And,(M.Test(M.And,onlyobj_val,onlysort_val)),onlyrel_val)))
+ in
+ let letin_query =
+ if ! letin = [] then fun x -> x
+ else
+ let f (vvar, msval) x = M.LetVVar(vvar,msval,x) in
+ iter f (fun x y z -> x (y z)) ! letin
+ in
+ letin_query (select_query must_query)
+
+(* high-level functions ****************************************************)
+
+let query_of_constraints u (musts_obj, musts_rel, musts_sort)
+ (onlys_obj, onlys_rel, onlys_sort) =
+ let conv = function
+ | `MainHypothesis None -> [T.MainHypothesis], []
+ | `MainHypothesis (Some d) -> [T.MainHypothesis], [d]
+ | `MainConclusion None -> [T.MainConclusion], []
+ | `MainConclusion (Some d) -> [T.MainConclusion], [d]
+ | `InHypothesis -> [T.InHypothesis], []
+ | `InConclusion -> [T.InConclusion], []
+ | `InBody -> [T.InBody], []
+ in
+ let must_obj (p, u) = let p, d = conv p in T.MustObj ([u], p, d) in
+ let must_sort (p, s) = let p, d = conv p in T.MustSort ([s], p, d) in
+ let must_rel p = let p, d = conv p in T.MustRel (p, d) in
+ let only_obj (p, u) = let p, d = conv p in T.OnlyObj ([u], p, d) in
+ let only_sort (p, s) = let p, d = conv p in T.OnlySort ([s], p, d) in
+ let only_rel p = let p, d = conv p in T.OnlyRel (p, d) in
+ let must = List.map must_obj musts_obj @
+ List.map must_rel musts_rel @
+ List.map must_sort musts_sort
+ in
+ let only =
+ (match onlys_obj with
+ | None -> []
+ | Some [] -> [T.OnlyObj ([], [], [])]
+ | Some l -> List.map only_obj l
+ ) @
+ (match onlys_rel with
+ | None -> []
+ | Some [] -> [T.OnlyRel ([], [])]
+ | Some l -> List.map only_rel l
+ ) @
+ (match onlys_sort with
+ | None -> []
+ | Some [] -> [T.OnlySort ([], [], [])]
+ | Some l -> List.map only_sort l
+ )
+ in
+ let univ = match u with None -> [] | Some l -> [T.Universe l] in
+ compose (must @ only @ univ)
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+(* interface for the low-level constraints *********************************)
+
+val locate : string -> MathQL.query
+
+val unreferred : string -> string -> MathQL.query
+
+val compose : MQGTypes.spec list -> MathQL.query
+
+(* interface for the high-level constraints ********************************)
+
+val query_of_constraints : MQGTypes.universe option ->
+ MQGTypes.must_restrictions ->
+ MQGTypes.only_restrictions ->
+ MathQL.query
--- /dev/null
+mQIPostgres.cmi: mQITypes.cmo
+mQIMySql.cmi: mQITypes.cmo
+mQIConn.cmi: mQITypes.cmo mQIMap.cmi
+mQIProperty.cmi: mQITypes.cmo mQIConn.cmi
+mQueryInterpreter.cmi: mQIConn.cmi
+mQueryTParser.cmo: mQueryTParser.cmi
+mQueryTParser.cmx: mQueryTParser.cmi
+mQueryTLexer.cmo: mQueryTParser.cmi
+mQueryTLexer.cmx: mQueryTParser.cmx
+mQueryUtil.cmo: mQueryTParser.cmi mQueryTLexer.cmo mQueryUtil.cmi
+mQueryUtil.cmx: mQueryTParser.cmx mQueryTLexer.cmx mQueryUtil.cmi
+mQIUtil.cmo: mQIUtil.cmi
+mQIUtil.cmx: mQIUtil.cmi
+mQIPostgres.cmo: mQIPostgres.cmi
+mQIPostgres.cmx: mQIPostgres.cmi
+mQIMySql.cmo: mQIMySql.cmi
+mQIMySql.cmx: mQIMySql.cmi
+mQIMap.cmo: mQueryUtil.cmi mQIMap.cmi
+mQIMap.cmx: mQueryUtil.cmx mQIMap.cmi
+mQIConn.cmo: mQIPostgres.cmi mQIMySql.cmi mQIMap.cmi mQIConn.cmi
+mQIConn.cmx: mQIPostgres.cmx mQIMySql.cmx mQIMap.cmx mQIConn.cmi
+mQIProperty.cmo: mQIUtil.cmi mQIMap.cmi mQIConn.cmi mQIProperty.cmi
+mQIProperty.cmx: mQIUtil.cmx mQIMap.cmx mQIConn.cmx mQIProperty.cmi
+mQueryInterpreter.cmo: mQueryUtil.cmi mQIUtil.cmi mQIProperty.cmi mQIConn.cmi \
+ mQueryInterpreter.cmi
+mQueryInterpreter.cmx: mQueryUtil.cmx mQIUtil.cmx mQIProperty.cmx mQIConn.cmx \
+ mQueryInterpreter.cmi
--- /dev/null
+PACKAGE = mathql_interpreter
+
+PREDICATES =
+
+INTERFACE_FILES = mQueryUtil.mli mQIUtil.mli \
+ mQIPostgres.mli mQIMySql.mli mQIMap.mli mQIConn.mli \
+ mQIProperty.mli mQueryInterpreter.mli
+
+IMPLEMENTATION_FILES = mQueryTParser.ml mQueryTLexer.ml \
+ mQITypes.ml $(INTERFACE_FILES:%.mli=%.ml)
+
+EXTRA_OBJECTS_TO_INSTALL = mQueryTLexer.cmi \
+ mQueryTLexer.mll mQueryTParser.mly \
+ mQITypes.ml mQITypes.cmi
+
+EXTRA_OBJECTS_TO_CLEAN = mQueryTParser.ml mQueryTParser.mli \
+ mQueryTLexer.ml
+
+include ../Makefile.common
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+(* $Id$ *)
+
+type connection = MySQL_C of HMysql.dbd
+ | Postgres_C of Postgres.connection
+ | No_C
+
+type flag = Galax | Postgres | Queries | Result | Source | Times | Warn
+
+type handle = {
+ log : string -> unit; (* logging function *)
+ set : flag list; (* options *)
+ pgc : connection; (* PG connection *)
+ pgm : MQIMap.pg_map; (* PG conversion function *)
+ pga : MQIMap.pg_alias (* PG table aliases *)
+}
+
+let tables handle p = MQIMap.get_tables handle.pgm p
+
+let field handle p t = MQIMap.get_field handle.pgm p t
+
+let resolve handle a = MQIMap.resolve handle.pga a
+
+let log handle = handle.log
+
+let set handle flag = List.mem flag handle.set
+
+let pgc handle = handle.pgc
+
+let flags handle = handle.set
+
+let string_of_flag = function
+ | Galax -> "G"
+ | Postgres -> "P"
+ | Queries -> "Q"
+ | Result -> "R"
+ | Source -> "S"
+ | Times -> "T"
+ | Warn -> "W"
+
+let flag_of_char = function
+ | 'G' -> [Galax]
+ | 'P' -> [Postgres]
+ | 'Q' -> [Queries]
+ | 'R' -> [Result]
+ | 'S' -> [Source]
+ | 'T' -> [Times]
+ | 'W' -> [Warn]
+ | _ -> []
+
+let string_fold_left f a s =
+ let l = String.length s in
+ let rec aux b i = if i = l then b else aux (f b s.[i]) (succ i) in
+ aux a 0
+
+let string_of_flags flags =
+ List.fold_left (fun s flag -> s ^ string_of_flag flag) "" flags
+
+let flags_of_string s =
+ string_fold_left (fun l c -> l @ flag_of_char c) [] s
+
+let init ?(flags = []) ?(log = ignore) () =
+ let flags =
+ if flags = [] then
+ flags_of_string (Helm_registry.get "mathql_interpreter.flags")
+ else
+ flags
+ in
+ let m, a =
+ let g =
+ if List.mem Galax flags
+ then MQIMap.empty_map else MQIMap.read_map
+ in g ()
+ in
+ {log = log; set = flags;
+ pgc = begin
+ try
+ if List.mem Galax flags then No_C else
+ if List.mem Postgres flags then Postgres_C (MQIPostgres.init ()) else
+ MySQL_C (MQIMySql.init ())
+ with Failure "mqi_connection" -> No_C
+ end;
+ pgm = m; pga = a
+ }
+
+let close handle =
+ match pgc handle with
+ | MySQL_C c -> MQIMySql.close c
+ | Postgres_C c -> MQIPostgres.close c
+ | No_C -> ()
+
+let exec handle out table cols ct cfl =
+ match pgc handle with
+ | MySQL_C c -> MQIMySql.exec (c, out) table cols ct cfl
+ | Postgres_C c -> MQIPostgres.exec (c, out) table cols ct cfl
+ | No_C -> []
+
+let connected handle =
+ pgc handle <> No_C
+
+let init_if_connected ?(flags = []) ?(log = ignore) () =
+ let handle = init ~flags:flags ~log:log () in
+ if connected handle then handle else raise (Failure "mqi connection failed")
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+type connection = MySQL_C of HMysql.dbd
+ | Postgres_C of Postgres.connection
+ | No_C
+
+type flag = Galax | Postgres | Queries | Result | Source | Times | Warn
+
+type handle = {
+ log : string -> unit; (* logging function *)
+ set : flag list; (* options *)
+ pgc : connection; (* PG connection *)
+ pgm : MQIMap.pg_map; (* PG conversion function *)
+ pga : MQIMap.pg_alias (* PG table aliases *)
+}
+
+val string_of_flags : flag list -> string
+val flags_of_string : string -> flag list
+
+val init : ?flags:(flag list) -> ?log:(string -> unit) -> unit -> handle
+val close : handle -> unit
+val connected : handle -> bool
+val exec : handle -> (MQITypes.query -> unit) ->
+ MQITypes.table -> MQITypes.columns ->
+ string MQITypes.con_true -> string MQITypes.con_false ->
+ MQITypes.result
+
+val init_if_connected : ?flags:(flag list) -> ?log:(string -> unit) -> unit -> handle
+
+(* The following functions allow to read the handle internal fields.
+ * For exclusive use of the interpreter.
+ *)
+
+val log : handle -> string -> unit
+val set : handle -> flag -> bool
+val flags : handle -> flag list
+val tables : handle -> MathQL.path -> MQIMap.pg_tables
+val field : handle -> MathQL.path -> string -> string
+val resolve : handle -> string -> string
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+(* $Id$ *)
+
+module U = MQueryUtil
+
+type pg_map = (MathQL.path * (bool * string * string option)) list
+
+type pg_tables = (bool * string) list
+
+type pg_alias = (string * string) list
+
+let empty_map () = [], []
+
+let read_map () =
+ let map = Helm_registry.get "mathql_interpreter.db_map" in
+ let ich = open_in map in
+ let rec aux r s =
+ let d = input_line ich in
+ match Str.split (Str.regexp "[ \t]+") d with
+ | [] -> aux r s
+ | "#" :: _ -> aux r s
+ | t :: "<-" :: p -> aux ((p, (false, t, None)) :: r) s
+ | t :: c :: "<-" :: p -> aux ((p, (false, t, Some c)) :: r) s
+ | t :: "<+" :: p -> aux ((p, (true, t, None)) :: r) s
+ | t :: c :: "<+" :: p -> aux ((p, (true, t, Some c)) :: r) s
+ | [a; "->"; t] -> aux r ((a, t) :: s)
+ | ["->"] -> r, s
+ | _ -> raise (Failure "MQIMap.read_map")
+ in
+ let pgm, pga = aux [] [] in
+ close_in ich;
+ pgm, pga
+
+let comp c1 c2 = match c1, c2 with
+ | (_, t1), (_, t2) when t1 < t2 -> U.Lt
+ | (_, t1), (_, t2) when t1 > t2 -> U.Gt
+ | (b1, t), (b2, _) -> U.Eq (b1 || b2, t)
+
+let get_tables pgm p =
+ let aux l = function
+ | q, (b, t, _) when q = p -> U.list_join comp l [(b, t)]
+ | _, _ -> l
+ in
+ List.fold_left aux [] pgm
+
+let rec refine_tables l1 l2 =
+ U.list_meet comp l1 l2
+
+let default_table = function
+ | [(_, a)] -> a
+ | l ->
+ try List.assoc true l
+ with Not_found -> raise (Failure "MQIMap.default_table")
+
+let get_field pgm p t =
+ let aux = function
+ | q, (_, u, _) when q = p && u = t -> true
+ | _ -> false
+ in
+ match List.filter aux pgm with
+ | [_, (_, _, None)] -> ""
+ | [_, (_, _, Some c)] -> c
+ | _ -> raise (Failure "MQIMap.get_field")
+
+let resolve pga a =
+ try List.assoc a pga with Not_found -> a
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+type pg_map (* mathql path map for postgres *)
+
+type pg_tables
+
+type pg_alias
+
+val empty_map : unit -> pg_map * pg_alias
+
+val read_map : unit -> pg_map * pg_alias
+
+val get_tables : pg_map -> MathQL.path -> pg_tables
+
+val refine_tables : pg_tables -> pg_tables -> pg_tables
+
+val default_table : pg_tables -> string
+
+val get_field : pg_map -> MathQL.path -> string -> string
+
+val resolve : pg_alias -> string -> string
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+(* $Id$ *)
+
+let init () =
+ let module HR = Helm_registry in
+ let host =
+ HR.get_opt HR.get_string "mathql_interpreter.mysql_connection.host" in
+ let database =
+ HR.get_opt HR.get_string "mathql_interpreter.mysql_connection.database" in
+ let user =
+ HR.get_opt HR.get_string "mathql_interpreter.mysql_connection.user" in
+ let port =
+ HR.get_opt HR.get_int "mathql_interpreter.mysql_connection.port" in
+ let password =
+ HR.get_opt HR.get_string "mathql_interpreter.mysql_connection.password" in
+ try HMysql.quick_connect ?host ?database ?user ?port ?password ()
+ with _ -> raise (Failure "mqi_connecion")
+
+let close c = HMysql.disconnect c
+
+let quote s =
+ let rec quote_aux s =
+ try
+ let l = String.length s in
+ let i = String.index s '\'' in
+ String.sub s 0 i ^ "\\'" ^ quote_aux (String.sub s (succ i) (l - (succ i)))
+ with Not_found -> s
+ in
+ "'" ^ quote_aux s ^ "'"
+
+let exec (c, out) q =
+ let g = function None -> "" | Some v -> v in
+ let f a = List.map g (Array.to_list a) in
+ out q; HMysql.map ~f:f (Mysql.exec c q)
+
+let exec c table cols ct cfl =
+ let rec iter f last sep = function
+ | [] -> last
+ | [head] -> f head
+ | head :: tail -> f head ^ sep ^ iter f last sep tail
+ in
+ let pg_cols = iter (fun x -> x) "" ", " cols in
+ let pg_msval v = iter quote "" ", " v in
+ let pg_con (pat, col, v) =
+ if col <> "" then
+ let f s = col ^ " regexp " ^ quote ("^" ^ s ^ "$") in
+ if pat then "(" ^ iter f "0" " or " v ^ ")"
+ else match v with
+ | [s] -> col ^ " = " ^ (quote s)
+ | v -> col ^ " in (" ^ pg_msval v ^ ")"
+ else "1"
+ in
+ let pg_cons l = iter pg_con "1" " and " l in
+ let pg_cons_not l = "not (" ^ pg_cons l ^ ")" in
+ let pg_cons_not_l ll = iter pg_cons_not "1" " and " ll in
+ let pg_where = match ct, cfl with
+ | [], [] -> ""
+ | lt, [] -> " where " ^ pg_cons lt
+ | [], llf -> " where " ^ pg_cons_not_l llf
+ | lt, llf -> " where " ^ pg_cons lt ^ " and " ^ pg_cons_not_l llf
+ in
+ if cols = [] then
+ let r = exec c ("select count(source) from " ^ table ^ pg_where) in
+ match r with
+ | [[s]] when int_of_string s > 0 -> [[]]
+ | _ -> []
+ else
+ exec c ("select " ^ pg_cols ^ " from " ^ table ^ pg_where ^
+ " order by " ^ List.hd cols ^ " asc")
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+val init : unit -> HMysql.dbd
+
+val close : HMysql.dbd -> unit
+
+val exec : HMysql.dbd * (MQITypes.query -> unit) ->
+ MQITypes.table -> MQITypes.columns ->
+ string MQITypes.con_true -> string MQITypes.con_false ->
+ MQITypes.result
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+(* $Id$ *)
+
+let init () =
+ let connection_string =
+ Helm_registry.get "mathql_interpreter.postgresql_connection_string"
+ in
+ try new Postgres.connection connection_string
+ with _ -> raise (Failure "mqi_connecion")
+
+let close c = c#close
+
+let quote s =
+ let rec quote_aux s =
+ try
+ let l = String.length s in
+ let i = String.index s '\'' in
+ String.sub s 0 i ^ "\\'" ^ quote_aux (String.sub s (succ i) (l - (succ i)))
+ with Not_found -> s
+ in
+ "'" ^ quote_aux s ^ "'"
+
+let exec (c, out) q = out q; (c#exec q)#get_list
+
+let exec c table cols ct cfl =
+ let rec iter f last sep = function
+ | [] -> last
+ | [head] -> f head
+ | head :: tail -> f head ^ sep ^ iter f last sep tail
+ in
+ let pg_cols = iter (fun x -> x) "" ", " cols in
+ let pg_msval v = iter quote "" ", " v in
+ let pg_con (pat, col, v) =
+ if col <> "" then
+ let f s = col ^ " ~ " ^ quote ("^" ^ s ^ "$") in
+ if pat then "(" ^ iter f "false" " or " v ^ ")"
+ else match v with
+ | [s] -> col ^ " = " ^ (quote s)
+ | v -> col ^ " in (" ^ pg_msval v ^ ")"
+ else "true"
+ in
+ let pg_cons l = iter pg_con "true" " and " l in
+ let pg_cons_not l = "not (" ^ pg_cons l ^ ")" in
+ let pg_cons_not_l ll = iter pg_cons_not "true" " and " ll in
+ let pg_where = match ct, cfl with
+ | [], [] -> ""
+ | lt, [] -> " where " ^ pg_cons lt
+ | [], llf -> " where " ^ pg_cons_not_l llf
+ | lt, llf -> " where " ^ pg_cons lt ^ " and " ^ pg_cons_not_l llf
+ in
+ if cols = [] then
+ let r = exec c ("select count(source) from " ^ table ^ pg_where) in
+ match r with
+ | [[s]] when int_of_string s > 0 -> [[]]
+ | _ -> []
+ else
+ exec c ("select " ^ pg_cols ^ " from " ^ table ^ pg_where ^
+ " order by " ^ List.hd cols ^ " asc")
+
+(* funzioni vecchie ********************************************************)
+(*
+let pg_name h s =
+ let q = "select id from registry where uri = " ^ quote s in
+ match exec h q with
+ | [[id]] -> "t" ^ id
+ | _ -> ""
+
+let get_id b = if b then ["B"] else ["F"]
+*)
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+val init : unit -> Postgres.connection
+
+val close : Postgres.connection -> unit
+
+val exec : Postgres.connection * (MQITypes.query -> unit) ->
+ MQITypes.table -> MQITypes.columns ->
+ string MQITypes.con_true -> string MQITypes.con_false ->
+ MQITypes.result
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+(* $Id$ *)
+
+module M = MathQL
+module C = MQIConn
+module U = MQIUtil
+module A = MQIMap
+
+let not_supported s =
+ raise (Failure ("MQIProperty: feature not supported: " ^ s))
+
+(* debugging ***************************************************************)
+
+let pg_print l =
+ let rec pg_record = function
+ | [] -> prerr_newline ()
+ | head :: tail -> prerr_string (head ^ " "); pg_record tail
+ in
+ List.iter pg_record l
+
+let cl_print l =
+ let c_print (b, p, v) =
+ prerr_string (if b then "match " else "in ");
+ List.iter (fun x -> prerr_string ("/" ^ x)) p;
+ prerr_newline ();
+ List.iter prerr_endline v
+ in
+ List.iter c_print l
+
+(* Common functions ********************************************************)
+
+let pg_result distinct subj el res =
+ let compose = if distinct then List.map else fun f -> U.mql_iter (fun x -> [f x]) in
+ let get_name = function (p, None) -> p | (_, Some p) -> p in
+ let names = List.map get_name el in
+ let mk_grp l =
+ let grp = U.mql_iter2 (fun p s -> [(p, [s])]) names l in
+ if grp = [] then [] else [grp]
+ in
+ let mk_avs l =
+ if subj = "" then ("", mk_grp l) else (List.hd l, mk_grp (List.tl l))
+ in
+ compose mk_avs res
+
+let get_table h mc ct cfl el =
+ let aux_c ts (_, p, _) = A.refine_tables ts (C.tables h p) in
+ let aux_e ts (p, _) = A.refine_tables ts (C.tables h p) in
+ let fst = C.tables h mc in
+ let snd = List.fold_left aux_c fst (ct @ (List.concat cfl)) in
+ let trd = List.fold_left aux_e snd el in
+ A.default_table trd
+
+let exec_single h mc ct cfl el table =
+ let conv p = C.field h p table in
+ let first = conv mc in
+ let mk_con l = List.map (fun (pat, p, v) -> (pat, conv p, v)) l in
+ let cons_true = mk_con ct in
+ let cons_false = List.map mk_con cfl in
+ let other_cols = List.map (fun (p, _) -> conv p) el in
+ let cols = if first = "" then other_cols else first :: other_cols in
+ let out q = if C.set h C.Queries then C.log h (q ^ "\n") in
+ let r = C.exec h out (C.resolve h table) cols cons_true cons_false in
+ pg_result false first el r
+
+let deadline = 100
+
+let exec h refine mc ct cfl el =
+ if refine <> M.RefineExact then not_supported "exec";
+ let table = get_table h mc ct cfl el in
+ let rec exec_aux ct = match ct with
+ | (pat, p, v) :: tail when List.length v > deadline ->
+ let single s = exec_aux ((pat, p, [s]) :: tail) in
+ U.mql_iter single v
+ | _ ->
+ exec_single h mc ct cfl el table
+ in exec_aux ct
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+val exec: MQIConn.handle ->
+ MathQL.refine -> MathQL.path ->
+ MathQL.path MQITypes.con_true -> MathQL.path MQITypes.con_false ->
+ MathQL.exp_list -> MathQL.result
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+(* $Id$ *)
+
+type 'a con = MathQL.pattern * 'a * MathQL.value
+
+type 'a con_true = 'a con list
+
+type 'a con_false = 'a con list list
+
+type table = string
+
+type columns = string list
+
+type result = string list list
+
+type query = string
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+(* $Id$ *)
+
+(* boolean constants *******************************************************)
+
+let mql_false = []
+
+let mql_true = [""]
+
+(* set theoretic operations *************************************************)
+
+let rec set_sub v1 v2 =
+ match v1, v2 with
+ | [], _ -> mql_true
+ | _, [] -> mql_false
+ | h1 :: _, h2 :: _ when h1 < h2 -> mql_false
+ | h1 :: _, h2 :: t2 when h1 > h2 -> set_sub v1 t2
+ | _ :: t1, _ :: t2 -> set_sub t1 t2
+
+let rec set_meet v1 v2 =
+ match v1, v2 with
+ | [], _ -> mql_false
+ | _, [] -> mql_false
+ | h1 :: t1, h2 :: _ when h1 < h2 -> set_meet t1 v2
+ | h1 :: _, h2 :: t2 when h1 > h2 -> set_meet v1 t2
+ | _, _ -> mql_true
+
+let set_eq v1 v2 =
+ if v1 = v2 then mql_true else mql_false
+
+let rec set_union v1 v2 =
+ match v1, v2 with
+ | [], v -> v
+ | v, [] -> v
+ | h1 :: t1, h2 :: t2 when h1 < h2 -> h1 :: set_union t1 v2
+ | h1 :: t1, h2 :: t2 when h1 > h2 -> h2 :: set_union v1 t2
+ | h1 :: t1, _ :: t2 -> h1 :: set_union t1 t2
+
+let rec set_intersect v1 v2 =
+ match v1, v2 with
+ | [], v -> []
+ | v, [] -> []
+ | h1 :: t1, h2 :: _ when h1 < h2 -> set_intersect t1 v2
+ | h1 :: _, h2 :: t2 when h1 > h2 -> set_intersect v1 t2
+ | h1 :: t1, _ :: t2 -> h1 :: set_intersect t1 t2
+
+let rec iter f = function
+ | [] -> []
+ | head :: tail -> set_union (f head) (iter f tail)
+
+(* MathQL specific set operations ******************************************)
+
+let rec mql_union s1 s2 =
+ match s1, s2 with
+ | [], s -> s
+ | s, [] -> s
+ | (r1, g1) :: t1, (r2, _) :: _ when r1 < r2 ->
+ (r1, g1) :: mql_union t1 s2
+ | (r1, _) :: _, (r2, g2) :: t2 when r1 > r2 ->
+ (r2, g2) :: mql_union s1 t2
+ | (r1, g1) :: t1, (_, g2) :: t2 ->
+ (r1, set_union g1 g2) :: mql_union t1 t2
+
+let rec mql_iter f = function
+ | [] -> []
+ | head :: tail -> mql_union (f head) (mql_iter f tail)
+
+let rec mql_iter2 f l1 l2 = match l1, l2 with
+ | [], [] -> []
+ | h1 :: t1, h2 :: t2 -> mql_union (f h1 h2) (mql_iter2 f t1 t2)
+ | _ -> raise (Invalid_argument "mql_iter2")
+
+let rec mql_prod g1 g2 =
+ let mql_prod_aux a = iter (fun h -> [mql_union a h]) g2 in
+ iter mql_prod_aux g1
+
+let rec mql_intersect s1 s2 =
+ match s1, s2 with
+ | [], s -> []
+ | s, [] -> []
+ | (r1, _) :: t1, (r2, _) :: _ when r1 < r2 -> mql_intersect t1 s2
+ | (r1, _) :: _, (r2, _) :: t2 when r1 > r2 -> mql_intersect s1 t2
+ | (r1, g1) :: t1, (_, g2) :: t2 ->
+ (r1, set_intersect g1 g2) :: mql_intersect t1 t2
+
+let rec mql_diff s1 s2 =
+ match s1, s2 with
+ | [], _ -> []
+ | s, [] -> s
+ | (r1, g1) :: t1 , (r2, _) ::_ when r1 < r2 ->
+ (r1, g1) :: (mql_diff t1 s2)
+ | (r1, _) :: _, (r2, _) :: t2 when r1 > r2 -> mql_diff s1 t2
+ | _ :: t1, _ :: t2 -> mql_diff t1 t2
+
+(* logic operations ********************************************************)
+
+let xor v1 v2 =
+ let b = v1 <> mql_false in
+ if b && v2 <> mql_false then mql_false else
+ if b then v1 else v2
+
+(* numeric operations ******************************************************)
+
+let int_of_list = function
+ | [s] -> int_of_string s
+ | _ -> raise (Failure "int_of_list")
+
+let le v1 v2 =
+ try if int_of_list v1 <= int_of_list v2 then mql_true else mql_false
+ with _ -> mql_false
+
+let lt v1 v2 =
+ try if int_of_list v1 < int_of_list v2 then mql_true else mql_false
+ with _ -> mql_false
+
+let align n v =
+ let c = String.length v in
+ try
+ let l = int_of_list [n] in
+ if c < l then [(String.make (l - c) ' ') ^ v] else [v]
+ with _ -> [v]
+
+(* context handling ********************************************************)
+
+let rec set ap = function
+ | [] -> [ap]
+ | head :: tail when fst head = fst ap -> ap :: tail
+ | head :: tail -> head :: set ap tail
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+val mql_true : MathQL.value
+
+val mql_false : MathQL.value
+
+val set_sub : MathQL.value -> MathQL.value -> MathQL.value
+
+val set_meet : MathQL.value -> MathQL.value -> MathQL.value
+
+val set_eq : MathQL.value -> MathQL.value -> MathQL.value
+
+val set_union : 'a list -> 'a list -> 'a list
+
+val set_intersect : 'a list -> 'a list -> 'a list
+
+val mql_union : ('a * 'b list) list -> ('a * 'b list) list ->
+ ('a * 'b list) list
+
+val mql_prod : MathQL.attribute_set -> MathQL.attribute_set ->
+ MathQL.attribute_set
+
+val mql_intersect : MathQL.result -> MathQL.result -> MathQL.result
+
+val mql_diff : MathQL.result -> MathQL.result -> MathQL.result
+
+val iter : ('a -> 'b list) -> 'a list -> 'b list
+
+val mql_iter : ('c -> ('a * 'b list) list) -> 'c list ->
+ ('a * 'b list) list
+
+val mql_iter2 : ('c -> 'd -> ('a * 'b list) list) -> 'c list ->
+ 'd list -> ('a * 'b list) list
+
+val xor : MathQL.value -> MathQL.value -> MathQL.value
+
+val le : MathQL.value -> MathQL.value -> MathQL.value
+
+val lt : MathQL.value -> MathQL.value -> MathQL.value
+
+val align : string -> string -> MathQL.value
+
+val set : string * 'a -> (string * 'a) list -> (string * 'a) list
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+(* $Id$ *)
+
+(* contexts *****************************************************************)
+
+type svar_context = (MathQL.svar * MathQL.resource_set) list
+
+type avar_context = (MathQL.avar * MathQL.resource) list
+
+type group_context = (MathQL.avar * MathQL.attribute_group) list
+
+type vvar_context = (MathQL.vvar * MathQL.value) list
+
+type context = {svars: svar_context;
+ avars: avar_context;
+ groups: group_context; (* auxiliary context *)
+ vvars: vvar_context
+ }
+
+(* execute *****************************************************************)
+
+exception Found
+
+module M = MathQL
+module P = MQueryUtil
+module C = MQIConn
+module U = MQIUtil
+
+let execute h x =
+ let warn q =
+ if C.set h C.Warn then
+ begin
+ C.log h "MQIExecute: waring: reference to undefined variables: ";
+ P.text_of_query (C.log h) "\n" q
+ end
+ in
+ let rec eval_val c = function
+ | M.False -> U.mql_false
+ | M.True -> U.mql_true
+ | M.Const s -> [s]
+ | M.Set l -> U.iter (eval_val c) l
+ | M.Test (k,y1,y2) ->
+ let cand y1 y2 =
+ if eval_val c y1 = U.mql_false then U.mql_false else eval_val c y2
+ in
+ let cor y1 y2 =
+ let v1 = eval_val c y1 in
+ if v1 = U.mql_false then eval_val c y2 else v1
+ in
+ let h f y1 y2 = f (eval_val c y1) (eval_val c y2) in
+ let f = match k with
+ | M.And -> cand
+ | M.Or -> cor
+ | M.Xor -> h U.xor
+ | M.Sub -> h U.set_sub
+ | M.Meet -> h U.set_meet
+ | M.Eq -> h U.set_eq
+ | M.Le -> h U.le
+ | M.Lt -> h U.lt
+ in
+ f y1 y2
+ | M.Not y ->
+ if eval_val c y = U.mql_false then U.mql_true else U.mql_false
+ | M.VVar i -> begin
+ try List.assoc i c.vvars
+ with Not_found -> warn (M.Subj (M.VVar i)); [] end
+ | M.Dot (i,p) -> begin
+ try List.assoc p (List.assoc i c.groups)
+ with Not_found -> warn (M.Subj (M.Dot (i,p))); [] end
+ | M.Proj (None,x) -> List.map (fun (r, _) -> r) (eval_query c x)
+ | M.Proj ((Some p),x) ->
+ let proj_group_aux (q, v) = if q = p then v else [] in
+ let proj_group a = U.iter proj_group_aux a in
+ let proj_set (_, g) = U.iter proj_group g in
+ U.iter proj_set (eval_query c x)
+ | M.Ex (l,y) ->
+ let rec ex_aux h = function
+ | [] ->
+ let d = {c with groups = h} in
+ if eval_val d y = U.mql_false then () else raise Found
+ | i :: tail ->
+ begin
+ try
+ let (_, a) = List.assoc i c.avars in
+ let rec add_group = function
+ | [] -> ()
+ | g :: t -> ex_aux ((i, g) :: h) tail; add_group t
+ in
+ add_group a
+ with Not_found -> ()
+ end
+ in
+ (try ex_aux [] l; U.mql_false with Found -> U.mql_true)
+ | M.StatVal y ->
+ let t = P.start_time () in
+ let r = (eval_val c y) in
+ let s = P.stop_time t in
+ C.log h (Printf.sprintf "Stat: %s,%i\n" s (List.length r));
+ r
+ | M.Count y -> [string_of_int (List.length (eval_val c y))]
+ | M.Align (s,y) -> U.iter (U.align s) (eval_val c y)
+ and eval_query c = function
+ | M.Empty -> []
+ | M.Subj x ->
+ List.map (fun s -> (s, [])) (eval_val c x)
+ | M.Log (_,b,x) ->
+ if b then begin
+ let t = P.start_time () in
+ P.text_of_query (C.log h) "\n" x;
+ let s = P.stop_time t in
+ if C.set h C.Times then
+ C.log h (Printf.sprintf "Log source: %s\n" s);
+ eval_query c x
+ end else begin
+ let s = (eval_query c x) in
+ let t = P.start_time () in
+ P.text_of_result (C.log h) "\n" s;
+ let r = P.stop_time t in
+ if C.set h C.Times then
+ C.log h (Printf.sprintf "Log: %s\n" r);
+ s
+ end
+ | M.If (y,x1,x2) ->
+ if (eval_val c y) = U.mql_false
+ then (eval_query c x2) else (eval_query c x1)
+ | M.Bin (k,x1,x2) ->
+ let f = match k with
+ | M.BinFJoin -> U.mql_union
+ | M.BinFMeet -> U.mql_intersect
+ | M.BinFDiff -> U.mql_diff
+ in
+ f (eval_query c x1) (eval_query c x2)
+ | M.SVar i -> begin
+ try List.assoc i c.svars
+ with Not_found -> warn (M.SVar i); [] end
+ | M.AVar i -> begin
+ try [List.assoc i c.avars]
+ with Not_found -> warn (M.AVar i); [] end
+ | M.LetSVar (i,x1,x2) ->
+ let d = {c with svars = U.set (i, eval_query c x1) c.svars} in
+ eval_query d x2
+ | M.LetVVar (i,y,x) ->
+ let d = {c with vvars = U.set (i, eval_val c y) c.vvars} in
+ eval_query d x
+ | M.For (k,i,x1,x2) ->
+ let f = match k with
+ | M.GenFJoin -> U.mql_union
+ | M.GenFMeet -> U.mql_intersect
+ in
+ let rec for_aux = function
+ | [] -> []
+ | h :: t ->
+ let d = {c with avars = U.set (i, h) c.avars} in
+ f (eval_query d x2) (for_aux t)
+ in
+ for_aux (eval_query c x1)
+ | M.Add (b,z,x) ->
+ let f = if b then U.mql_prod else U.set_union in
+ let g a s = (fst a, f (snd a) (eval_grp c z)) :: s in
+ List.fold_right g (eval_query c x) []
+ | M.Property (q0,q1,q2,mc,ct,cfl,el,pat,y) ->
+ let subj, mct =
+ if q0 then [], (pat, q2 @ mc, eval_val c y)
+ else (q2 @ mc), (pat, [], eval_val c y)
+ in
+ let eval_cons (pat, p, y) = (pat, q2 @ p, eval_val c y) in
+ let cons_true = mct :: List.map eval_cons ct in
+ let cons_false = List.map (List.map eval_cons) cfl in
+ let eval_exp (p, po) = (q2 @ p, po) in
+ let exp = List.map eval_exp el in
+ let t = P.start_time () in
+ let r = MQIProperty.exec h q1 subj cons_true cons_false exp in
+ let s = P.stop_time t in
+ if C.set h C.Times then
+ C.log h (Printf.sprintf "Property: %s,%i\n" s (List.length r));
+ r
+ | M.StatQuery x ->
+ let t = P.start_time () in
+ let r = (eval_query c x) in
+ let s = P.stop_time t in
+ C.log h (Printf.sprintf "Stat: %s,%i\n" s (List.length r));
+ r
+ | M.Select (i,x,y) ->
+ let rec select_aux = function
+ | [] -> []
+ | h :: t ->
+ let d = {c with avars = U.set (i, h) c.avars} in
+ if eval_val d y = U.mql_false
+ then select_aux t else h :: select_aux t
+ in
+ select_aux (eval_query c x)
+ | M.Keep (b,l,x) ->
+ let keep_path (p, v) t =
+ if List.mem p l = b then t else (p, v) :: t in
+ let keep_grp a = List.fold_right keep_path a [] in
+ let keep_set a g =
+ let kg = keep_grp a in
+ if kg = [] then g else kg :: g
+ in
+ let keep_av (s, g) = (s, List.fold_right keep_set g []) in
+ List.map keep_av (eval_query c x)
+ and eval_grp c = function
+ | M.Attr gs ->
+ let attr_aux g (p, y) = U.mql_union g [(p, eval_val c y)] in
+ let attr_auxs s l = U.set_union s [List.fold_left attr_aux [] l] in
+ List.fold_left attr_auxs [] gs
+ | M.From i ->
+ try snd (List.assoc i c.avars)
+ with Not_found -> warn (M.AVar i); []
+ in
+ let c = {svars = []; avars = []; groups = []; vvars = []} in
+ let t = P.start_time () in
+ if C.set h C.Source then P.text_of_query (C.log h) "\n" x;
+ let r = eval_query c x in
+ if C.set h C.Result then P.text_of_result (C.log h) "\n" r;
+ let s = P.stop_time t in
+ if C.set h C.Times then
+ C.log h (Printf.sprintf "MQIExecute: %s,%s\n" s
+ (C.string_of_flags (C.flags h)));
+ r
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+val execute : MQIConn.handle -> MathQL.query -> MathQL.result
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+{
+ open MQueryTParser
+
+ let debug = false
+
+ let out s = if debug then prerr_endline s
+}
+
+let SPC = [' ' '\t' '\n']+
+let ALPHA = ['A'-'Z' 'a'-'z' '_']
+let NUM = ['0'-'9']
+let IDEN = ALPHA (NUM | ALPHA)*
+let QSTR = [^ '"' '\\']+
+
+rule comm_token = parse
+ | "(*" { comm_token lexbuf; comm_token lexbuf }
+ | "*)" { () }
+ | ['*' '('] { comm_token lexbuf }
+ | [^ '*' '(']* { comm_token lexbuf }
+and string_token = parse
+ | '"' { DQ }
+ | '\\' _ { STR (String.sub (Lexing.lexeme lexbuf) 1 1) }
+ | QSTR { STR (Lexing.lexeme lexbuf) }
+ | eof { EOF }
+and query_token = parse
+ | "(*" { comm_token lexbuf; query_token lexbuf }
+ | SPC { query_token lexbuf }
+ | '"' { let str = qstr string_token lexbuf in
+ out ("STR " ^ str); STR str }
+ | '(' { out "LP"; LP }
+ | ')' { out "RP"; RP }
+ | '{' { out "LC"; LC }
+ | '}' { out "RC"; RC }
+ | '@' { out "AT"; AT }
+ | '%' { out "PC"; PC }
+ | '$' { out "DL"; DL }
+ | '.' { out "FS"; FS }
+ | ',' { out "CM"; CM }
+ | ';' { out "SC"; SC }
+ | '/' { out "SL"; SL }
+ | "add" { out "ADD" ; ADD }
+ | "align" { out "ALIGN" ; ALIGN }
+ | "allbut" { out "BUT" ; BUT }
+ | "and" { out "AND" ; AND }
+ | "as" { out "AS" ; AS }
+ | "attr" { out "ATTR" ; ATTR }
+ | "be" { out "BE" ; BE }
+ | "count" { out "COUNT" ; COUNT }
+ | "diff" { out "DIFF" ; DIFF }
+ | "distr" { out "DISTR" ; DISTR }
+ | "else" { out "ELSE" ; ELSE }
+ | "empty" { out "EMPTY" ; EMPTY }
+ | "eq" { out "EQ" ; EQ }
+ | "ex" { out "EX" ; EX }
+ | "false" { out "FALSE" ; FALSE }
+ | "for" { out "FOR" ; FOR }
+ | "from" { out "FROM" ; FROM }
+ | "if" { out "IF" ; IF }
+ | "in" { out "IN" ; IN }
+ | "inf" { out "INF" ; INF }
+ | "intersect" { out "INTER" ; INTER }
+ | "inverse" { out "INV" ; INV }
+ | "istrue" { out "IST" ; IST }
+ | "isfalse" { out "ISF" ; ISF }
+ | "keep" { out "KEEP" ; KEEP }
+ | "le" { out "LE" ; LE }
+ | "let" { out "LET" ; LET }
+ | "log" { out "LOG" ; LOG }
+ | "lt" { out "LT" ; LT }
+ | "main" { out "MAIN" ; MAIN }
+ | "match" { out "MATCH" ; MATCH }
+ | "meet" { out "MEET" ; MEET }
+ | "not" { out "NOT" ; NOT }
+ | "of" { out "OF" ; OF }
+ | "or" { out "OR" ; OR }
+ | "pattern" { out "PAT" ; PAT }
+ | "proj" { out "PROJ" ; PROJ }
+ | "property" { out "PROP" ; PROP }
+ | "select" { out "SELECT"; SELECT }
+ | "source" { out "SOURCE"; SOURCE }
+ | "stat" { out "STAT" ; STAT }
+ | "sub" { out "SUB" ; SUB }
+ | "subj" { out "SUBJ" ; SUBJ }
+ | "sup" { out "SUP" ; SUP }
+ | "super" { out "SUPER" ; SUPER }
+ | "then" { out "THEN" ; THEN }
+ | "true" { out "TRUE" ; TRUE }
+ | "union" { out "UNION" ; UNION }
+ | "where" { out "WHERE" ; WHERE }
+ | "xor" { out "XOR" ; XOR }
+ | IDEN { let id = Lexing.lexeme lexbuf in
+ out ("ID " ^ id); ID id }
+ | eof { out "EOF" ; EOF }
+and result_token = parse
+ | SPC { result_token lexbuf }
+ | "(*" { comm_token lexbuf; result_token lexbuf }
+ | '"' { STR (qstr string_token lexbuf) }
+ | '/' { out "SL"; SL }
+ | '{' { LC }
+ | '}' { RC }
+ | ',' { CM }
+ | ';' { SC }
+ | '=' { IS }
+ | "attr" { ATTR }
+ | eof { EOF }
--- /dev/null
+/* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ */
+
+/* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ */
+
+%{
+ module M = MathQL
+
+ let analyze x =
+ let rec join l1 l2 = match l1, l2 with
+ | [], _ -> l2
+ | _, [] -> l1
+ | s1 :: tl1, s2 :: _ when s1 < s2 -> s1 :: join tl1 l2
+ | s1 :: _, s2 :: tl2 when s2 < s1 -> s2 :: join l1 tl2
+ | s1 :: tl1, s2 :: tl2 -> s1 :: join tl1 tl2
+ in
+ let rec iter f = function
+ | [] -> []
+ | head :: tail -> join (f head) (iter f tail)
+ in
+ let rec an_val = function
+ | M.True -> []
+ | M.False -> []
+ | M.Const _ -> []
+ | M.VVar _ -> []
+ | M.Ex _ -> []
+ | M.Dot (rv,_) -> [rv]
+ | M.Not x -> an_val x
+ | M.StatVal x -> an_val x
+ | M.Count x -> an_val x
+ | M.Align (_,x) -> an_val x
+ | M.Proj (_,x) -> an_set x
+ | M.Test (_,x,y) -> iter an_val [x; y]
+ | M.Set l -> iter an_val l
+ and an_set = function
+ | M.Empty -> []
+ | M.SVar _ -> []
+ | M.AVar _ -> []
+ | M.Subj x -> an_val x
+ | M.Keep (_,_,x) -> an_set x
+ | M.Log (_,_,x) -> an_set x
+ | M.StatQuery x -> an_set x
+ | M.Bin (_,x,y) -> iter an_set [x; y]
+ | M.LetSVar (_,x,y) -> iter an_set [x; y]
+ | M.For (_,_,x,y) -> iter an_set [x; y]
+ | M.Add (_,g,x) -> join (an_grp g) (an_set x)
+ | M.LetVVar (_,x,y) -> join (an_val x) (an_set y)
+ | M.Select (_,x,y) -> join (an_set x) (an_val y)
+ | M.Property (_,_,_,_,c,d,_,_,x) ->
+ join (an_val x) (iter an_con [c; List.concat d])
+ | M.If (x,y,z) -> join (an_val x) (iter an_set [y; z])
+ and fc (_, _, v) = an_val v
+ and an_con c = iter fc c
+ and fg (_, v) = an_val v
+ and an_grp = function
+ | M.Attr g -> iter (iter fg) g
+ | M.From _ -> []
+ in
+ an_val x
+
+ let f (x, y, z) = x
+ let s (x, y, z) = y
+ let t (x, y, z) = z
+%}
+ %token <string> ID STR
+ %token SL IS LC RC CM SC LP RP AT PC DL FS DQ EOF
+ %token ADD ALIGN AND AS ATTR BE BUT COUNT DIFF DISTR ELSE EMPTY EQ EX
+ %token FALSE FOR FROM IF IN INF INTER INV ISF IST KEEP LE LET LOG LT
+ %token MAIN MATCH MEET NOT OF OR PAT PROJ PROP SELECT SOURCE STAT SUB
+ %token SUBJ SUP SUPER THEN TRUE UNION WHERE XOR
+ %nonassoc IN SUP INF ELSE LOG STAT
+ %left DIFF
+ %left UNION
+ %left INTER
+ %nonassoc WHERE EX
+ %left XOR OR
+ %left AND
+ %nonassoc NOT
+ %nonassoc SUB MEET EQ LT LE
+ %nonassoc SUBJ OF PROJ COUNT ALIGN
+
+ %start qstr query result
+ %type <string> qstr
+ %type <MathQL.query> query
+ %type <MathQL.result> result
+%%
+ qstr:
+ | DQ { "" }
+ | STR qstr { $1 ^ $2 }
+ ;
+ svar:
+ | PC ID { $2 }
+ ;
+ avar:
+ | AT ID { $2 }
+ ;
+ vvar:
+ | DL ID { $2 }
+ ;
+ strs:
+ | STR CM strs { $1 :: $3 }
+ | STR { [$1] }
+ ;
+ subpath:
+ | STR SL subpath { $1 :: $3 }
+ | STR { [$1] }
+ ;
+ path:
+ | subpath { $1 }
+ | SL subpath { $2 }
+ | SL { [] }
+ ;
+ paths:
+ | path CM paths { $1 :: $3 }
+ | path { [$1] }
+ inv:
+ | INV { true }
+ | { false }
+ ;
+ ref:
+ | SUB { M.RefineSub }
+ | SUPER { M.RefineSuper }
+ | { M.RefineExact }
+ ;
+ qualif:
+ | inv ref path { $1, $2, $3 }
+ ;
+ cons:
+ | path IN val_exp { (false, $1, $3) }
+ | path MATCH val_exp { (true, $1, $3) }
+ ;
+ conss:
+ | cons CM conss { $1 :: $3 }
+ | cons { [$1] }
+ ;
+ istrue:
+ | IST conss { $2 }
+ | { [] }
+ ;
+ isfalse:
+ | { [] }
+ | ISF conss isfalse { $2 :: $3 }
+ ;
+ mainc:
+ | MAIN path { $2 }
+ | { [] }
+ ;
+ exp:
+ | path AS path { $1, Some $3 }
+ | path { $1, None }
+ ;
+ exps:
+ | exp CM exps { $1 :: $3 }
+ | exp { [$1] }
+ ;
+ attrc:
+ | ATTR exps { $2 }
+ | { [] }
+ ;
+ pattern:
+ | PAT { true }
+ | { false }
+ ;
+ opt_path:
+ | path { Some $1 }
+ | { None }
+ ;
+ ass:
+ | val_exp AS path { ($3, $1) }
+ ;
+ asss:
+ | ass CM asss { $1 :: $3 }
+ | ass { [$1] }
+ ;
+ assg:
+ | asss SC assg { $1 :: $3 }
+ | asss { [$1] }
+ ;
+ distr:
+ | DISTR { true }
+ | { false }
+ ;
+ allbut:
+ | BUT { true }
+ | { false }
+ ;
+ bin_op:
+ | set_exp DIFF set_exp { M.BinFDiff, $1, $3 }
+ | set_exp UNION set_exp { M.BinFJoin, $1, $3 }
+ | set_exp INTER set_exp { M.BinFMeet, $1, $3 }
+ ;
+ gen_op:
+ | SUP set_exp { M.GenFJoin, $2 }
+ | INF set_exp { M.GenFMeet, $2 }
+ ;
+ test_op:
+ | val_exp XOR val_exp { M.Xor, $1, $3 }
+ | val_exp OR val_exp { M.Or, $1, $3 }
+ | val_exp AND val_exp { M.And, $1, $3 }
+ | val_exp SUB val_exp { M.Sub, $1, $3 }
+ | val_exp MEET val_exp { M.Meet, $1, $3 }
+ | val_exp EQ val_exp { M.Eq, $1, $3 }
+ | val_exp LE val_exp { M.Le, $1, $3 }
+ | val_exp LT val_exp { M.Lt, $1, $3 }
+ ;
+ source:
+ | SOURCE { true }
+ | { false }
+ ;
+ xml:
+ | { false}
+ ;
+ grp_exp:
+ | assg { M.Attr $1 }
+ | avar { M.From $1 }
+ ;
+ val_exp:
+ | TRUE { M.True }
+ | FALSE { M.False }
+ | STR { M.Const $1 }
+ | avar FS path { M.Dot ($1,$3) }
+ | vvar { M.VVar $1 }
+ | LC vals RC { M.Set $2 }
+ | LC RC { M.Set [] }
+ | LP val_exp RP { $2 }
+ | STAT val_exp { M.StatVal $2 }
+ | EX val_exp { M.Ex ((analyze $2),$2) }
+ | NOT val_exp { M.Not $2 }
+ | test_op { M.Test ((f $1),(s $1),(t $1)) }
+ | PROJ opt_path set_exp { M.Proj ($2,$3) }
+ | COUNT val_exp { M.Count $2 }
+ | ALIGN STR IN val_exp { M.Align ($2,$4) }
+ ;
+ vals:
+ | val_exp CM vals { $1 :: $3 }
+ | val_exp { [$1] }
+ ;
+ set_exp:
+ | EMPTY { M.Empty }
+ | LP set_exp RP { $2 }
+ | svar { M.SVar $1 }
+ | avar { M.AVar $1 }
+ | LET svar BE set_exp IN set_exp { M.LetSVar ($2,$4,$6) }
+ | LET vvar BE val_exp IN set_exp { M.LetVVar ($2,$4,$6) }
+ | FOR avar IN set_exp gen_op
+ { M.For ((fst $5),$2,$4,(snd $5)) }
+ | ADD distr grp_exp IN set_exp { M.Add ($2,$3,$5) }
+ | IF val_exp THEN set_exp ELSE set_exp { M.If ($2,$4,$6) }
+ | PROP qualif mainc istrue isfalse attrc OF pattern val_exp
+ { M.Property ((f $2),(s $2),(t $2),$3,$4,$5,$6,$8,$9) }
+ | LOG xml source set_exp { M.Log ($2,$3,$4) }
+ | STAT set_exp { M.StatQuery $2 }
+ | KEEP allbut paths IN set_exp { M.Keep ($2,$3,$5) }
+ | KEEP allbut IN set_exp { M.Keep ($2,[],$4) }
+ | bin_op
+ { M.Bin ((f $1),(s $1),(t $1)) }
+ | SELECT avar FROM set_exp WHERE val_exp { M.Select ($2,$4,$6) }
+ | SUBJ val_exp { M.Subj $2 }
+ ;
+ query:
+ | set_exp { $1 }
+ | set_exp error { $1 }
+ | EOF { raise End_of_file }
+ ;
+ attr:
+ | path IS strs { $1, $3 }
+ | path { $1, [] }
+ ;
+ attrs:
+ | attr SC attrs { $1 :: $3 }
+ | attr { [$1] }
+ ;
+ group:
+ LC attrs RC { $2 }
+ ;
+ groups:
+ | group CM groups { $1 :: $3 }
+ | group { [$1] }
+ ;
+ resource:
+ | STR ATTR groups { ($1, $3) }
+ | STR { ($1, []) }
+ ;
+ resources:
+ | resource SC resources { $1 :: $3 }
+ | resource { [$1] }
+ | { [] }
+ ;
+ result:
+ | resources { $1 }
+ | EOF { raise End_of_file }
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+(* $Id$ *)
+
+(* text linearization and parsing *******************************************)
+
+let rec txt_list out f s = function
+ | [] -> ()
+ | [a] -> f a
+ | a :: tail -> f a; out s; txt_list out f s tail
+
+let txt_str out s = out ("\"" ^ s ^ "\"")
+
+let txt_path out p = out "/"; txt_list out (txt_str out) "/" p
+
+let text_of_query out sep x =
+ let module M = MathQL in
+ let txt_path_list l = txt_list out (txt_path out) ", " l in
+ let txt_svar sv = out ("%" ^ sv) in
+ let txt_avar av = out ("@" ^ av) in
+ let txt_vvar vv = out ("$" ^ vv) in
+ let txt_inv i = if i then out "inverse " in
+ let txt_ref = function
+ | M.RefineExact -> ()
+ | M.RefineSub -> out "sub "
+ | M.RefineSuper -> out "super "
+ in
+ let txt_qualif i r p = txt_inv i; txt_ref r; txt_path out p in
+ let main = function
+ | [] -> ()
+ | p -> out " main "; txt_path out p
+ in
+ let txt_exp = function
+ | (pl, None) -> txt_path out pl
+ | (pl, Some pr) -> txt_path out pl; out " as "; txt_path out pr
+ in
+ let txt_exp_list = function
+ | [] -> ()
+ | l -> out " attr "; txt_list out txt_exp ", " l
+ in
+ let pattern b = if b then out "pattern " in
+ let txt_opt_path = function
+ | None -> ()
+ | Some p -> txt_path out p; out " "
+ in
+ let txt_distr d = if d then out "distr " in
+ let txt_bin = function
+ | M.BinFJoin -> out " union "
+ | M.BinFMeet -> out " intersect "
+ | M.BinFDiff -> out " diff "
+ in
+ let txt_gen = function
+ | M.GenFJoin -> out " sup "
+ | M.GenFMeet -> out " inf "
+ in
+ let txt_test = function
+ | M.Xor -> out " xor "
+ | M.Or -> out " or "
+ | M.And -> out " and "
+ | M.Sub -> out " sub "
+ | M.Meet -> out " meet "
+ | M.Eq -> out " eq "
+ | M.Le -> out " le "
+ | M.Lt -> out " lt "
+ in
+ let txt_log a b =
+ if a then out "xml ";
+ if b then out "source "
+ in
+ let txt_allbut b = if b then out "allbut " in
+ let rec txt_con (pat, p, x) =
+ txt_path out p;
+ if pat then out " match " else out " in ";
+ txt_val x
+ and txt_con_list s = function
+ | [] -> ()
+ | l -> out s; txt_list out txt_con ", " l
+ and txt_istrue lt = txt_con_list " istrue " lt
+ and txt_isfalse lf = txt_con_list " isfalse " lf
+ and txt_ass (p, x) = txt_val x; out " as "; txt_path out p
+ and txt_ass_list l = txt_list out txt_ass ", " l
+ and txt_assg_list g = txt_list out txt_ass_list "; " g
+ and txt_val_list = function
+ | [v] -> txt_val v
+ | l -> out "{"; txt_list out txt_val ", " l; out "}"
+ and txt_grp = function
+ | M.Attr g -> txt_assg_list g
+ | M.From av -> txt_avar av
+ and txt_val = function
+ | M.True -> out "true"
+ | M.False -> out "false"
+ | M.Const s -> txt_str out s
+ | M.Set l -> txt_val_list l
+ | M.VVar vv -> txt_vvar vv
+ | M.Dot (av,p) -> txt_avar av; out "."; txt_path out p
+ | M.Proj (op,x) -> out "proj "; txt_opt_path op; txt_set x
+ | M.Ex (b,x) -> out "ex "; txt_val x
+(* | M.Ex b x -> out "ex ["; txt_list out txt_avar "," b; out "] "; txt_val x
+*) | M.Not x -> out "not "; txt_val x
+ | M.Test (k,x,y) -> out "("; txt_val x; txt_test k; txt_val y; out ")"
+ | M.StatVal x -> out "stat "; txt_val x
+ | M.Count x -> out "count "; txt_val x
+ | M.Align (s,x) -> out "align "; txt_str out s; out " in "; txt_val x
+ and txt_set = function
+ | M.Empty -> out "empty"
+ | M.SVar sv -> txt_svar sv
+ | M.AVar av -> txt_avar av
+ | M.Property (q0,q1,q2,mc,ct,cfl,xl,b,x) ->
+ out "property "; txt_qualif q0 q1 q2; main mc;
+ txt_istrue ct; txt_list out txt_isfalse "" cfl; txt_exp_list xl;
+ out " of "; pattern b; txt_val x
+ | M.Bin (k,x,y) -> out "("; txt_set x; txt_bin k; txt_set y;
+ out ")"
+ | M.LetSVar (sv,x,y) -> out "let "; txt_svar sv; out " be ";
+ txt_set x; out " in "; txt_set y
+ | M.LetVVar (vv,x,y) -> out "let "; txt_vvar vv; out " be ";
+ txt_val x; out " in "; txt_set y
+ | M.Select (av,x,y) -> out "select "; txt_avar av; out " from ";
+ txt_set x; out " where "; txt_val y
+ | M.Subj x -> out "subj "; txt_val x
+ | M.For (k,av,x,y) -> out "for "; txt_avar av; out " in ";
+ txt_set x; txt_gen k; txt_set y
+ | M.If (x,y,z) -> out "if "; txt_val x; out " then ";
+ txt_set y; out " else "; txt_set z
+ | M.Add (d,g,x) -> out "add "; txt_distr d; txt_grp g;
+ out " in "; txt_set x
+ | M.Log (a,b,x) -> out "log "; txt_log a b; txt_set x
+ | M.StatQuery x -> out "stat "; txt_set x
+ | M.Keep (b,l,x) -> out "keep "; txt_allbut b; txt_path_list l;
+ txt_set x
+ in
+ txt_set x; out sep
+
+let text_of_result out sep x =
+ let txt_attr = function
+ | (p, []) -> txt_path out p
+ | (p, l) -> txt_path out p; out " = "; txt_list out (txt_str out) ", " l
+ in
+ let txt_group l = out "{"; txt_list out txt_attr "; " l; out "}" in
+ let txt_res = function
+ | (s, []) -> txt_str out s
+ | (s, l) -> txt_str out s; out " attr "; txt_list out txt_group ", " l
+ in
+ let txt_set l = txt_list out txt_res ("; " ^ sep) l; out sep in
+ txt_set x
+
+let query_of_text lexbuf =
+ MQueryTParser.query MQueryTLexer.query_token lexbuf
+
+let result_of_text lexbuf =
+ MQueryTParser.result MQueryTLexer.result_token lexbuf
+
+(* time handling ***********************************************************)
+
+type time = float * float
+
+let start_time () =
+ (Sys.time (), Unix.time ())
+
+let stop_time (s0, u0) =
+ let s1 = Sys.time () in
+ let u1 = Unix.time () in
+ Printf.sprintf "%.2fs,%.2fs" (s1 -. s0) (u1 -. u0)
+
+(* operations on lists *****************************************************)
+
+type 'a comparison = Lt
+ | Gt
+ | Eq of 'a
+
+let list_join f l1 l2 =
+ let rec aux = function
+ | [], v
+ | v, [] -> v
+ | ((h1 :: t1) as v1), ((h2 :: t2) as v2) -> begin
+ match f h1 h2 with
+ | Lt -> h1 :: aux (t1, v2)
+ | Gt -> h2 :: aux (v1, t2)
+ | Eq h -> h :: aux (t1, t2)
+ end
+ in aux (l1, l2)
+
+let list_meet f l1 l2 =
+ let rec aux = function
+ | [], v
+ | v, [] -> []
+ | ((h1 :: t1) as v1), ((h2 :: t2) as v2) -> begin
+ match f h1 h2 with
+ | Lt -> aux (t1, v2)
+ | Gt -> aux (v1, t2)
+ | Eq h -> h :: aux (t1, t2)
+ end
+ in aux (l1, l2)
+
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+val text_of_query : (string -> unit) -> string -> MathQL.query -> unit
+
+val text_of_result : (string -> unit) -> string -> MathQL.result -> unit
+
+val query_of_text : Lexing.lexbuf -> MathQL.query
+
+val result_of_text : Lexing.lexbuf -> MathQL.result
+
+type time
+
+val start_time : unit -> time
+
+val stop_time : time -> string
+
+type 'a comparison = Lt
+ | Gt
+ | Eq of 'a
+
+val list_join : ('a -> 'a -> 'a comparison) -> 'a list -> 'a list -> 'a list
+
+val list_meet : ('a -> 'a -> 'a comparison) -> 'a list -> 'a list -> 'a list
--- /dev/null
+*.cm[aiox] *.cmxa *.opt mqtop mqitop mqgtop examples*
+mQGTopParser.ml mQGTopParser.mli mQGTopLexer.ml
--- /dev/null
+mqgtop.cmo: mQGTopLexer.cmo mQGTopParser.cmi
+mqgtop.cmx: mQGTopLexer.cmx mQGTopParser.cmx
+mQGTopParser.cmo: mQGTopParser.cmi
+mQGTopParser.cmx: mQGTopParser.cmi
+mQGTopLexer.cmo: mQGTopParser.cmi
+mQGTopLexer.cmx: mQGTopParser.cmx
--- /dev/null
+BIN_DIR = /usr/local/bin
+REQUIRES = unix helm-registry helm-cic_textual_parser \
+ helm-mathql helm-mathql_interpreter helm-mathql_generator
+PREDICATES =
+OCAMLOPTIONS = -package "$(REQUIRES)" -predicates "$(PREDICATES)" -thread
+OCAMLC = ocamlfind ocamlc $(OCAMLOPTIONS)
+OCAMLOPT = ocamlfind ocamlopt $(OCAMLOPTIONS)
+OCAMLDEP = ocamldep
+OCAMLYACC = ocamlyacc
+OCAMLLEX = ocamllex
+
+LIBRARIES = $(shell ocamlfind query -recursive -predicates "byte $(PREDICATES)" -format "%d/%a" $(REQUIRES))
+LIBRARIES_OPT = $(shell ocamlfind query -recursive -predicates "native $(PREDICATES)" -format "%d/%a" $(REQUIRES))
+
+MQTOP = mqtop.ml
+MQITOP = mqitop.ml
+MQGTOP = mqgtop.ml
+
+DEPOBJS = $(MQTOP) $(MQITOP) $(MQGTOP)
+AUXOBJS = mQGTopParser.ml mQGTopParser.mli mQGTopLexer.ml
+
+all: $(DEPOBJS:.ml=)
+opt: $(DEPOBJS:.ml=.opt)
+
+depend: $(AUXOBJS)
+ $(OCAMLDEP) $(DEPOBJS) $(AUXOBJS) > .depend
+
+mqtop: $(MQTOP:.ml=.cmo) $(LIBRARIES)
+ $(OCAMLC) -linkpkg -o mqtop $(MQTOP:.ml=.cmo)
+
+mqtop.opt: $(MQTOP:.ml=.cmx) $(LIBRARIES_OPT)
+ $(OCAMLOPT) -linkpkg -o mqtop.opt $(MQTOP:.ml=.cmx)
+
+mqitop: $(MQITOP:.ml=.cmo) $(LIBRARIES)
+ $(OCAMLC) -linkpkg -o mqitop $(MQITOP:.ml=.cmo)
+
+mqitop.opt: $(MQITOP:.ml=.cmx) $(LIBRARIES_OPT)
+ $(OCAMLOPT) -linkpkg -o mqitop.opt $(MQITOP:.ml=.cmx)
+
+mqgtop: mQGTopParser.cmi $(AUXOBJS:.ml=.cmo) $(MQGTOP:.ml=.cmo) $(LIBRARIES)
+ $(OCAMLC) -linkpkg -o mqgtop $(AUXOBJS:.ml=.cmo) $(MQGTOP:.ml=.cmo)
+
+mqgtop.opt: $(AUXOBJS:.ml=.cmx) $(MQGTOP:.ml=.cmx) $(LIBRARIES_OPT)
+ $(OCAMLOPT) -linkpkg -o mqgtop.opt $(AUXOBJS:.ml=.cmx) $(MQGTOP:.ml=.cmx)
+
+.SUFFIXES: .ml .mli .cmo .cmi .cmx .mly .mll
+.ml.cmo: $(LIBRARIES)
+ $(OCAMLC) -c $<
+.mli.cmi: $(LIBRARIES)
+ $(OCAMLC) -c $<
+.ml.cmx: $(LIBRARIES_OPT)
+ $(OCAMLOPT) -c $<
+.mly.ml:
+ $(OCAMLYACC) $<
+.mly.mli:
+ $(OCAMLYACC) $<
+.mll.ml:
+ $(OCAMLLEX) $<
+
+$(DEPOBJS:%.ml=%.cmo): $(LIBRARIES)
+$(DEPOBJS:%.ml=%.cmx): $(LIBRARIES_OPT)
+
+clean:
+ rm -f *.cm[iox] *.o $(DEPOBJS:.ml=) $(DEPOBJS:.ml=.opt) \
+ mQGTopParser.ml mQGTopParser.mli mQGTopLexer.ml
+
+install:
+ cp $(DEPOBJS:.ml=) $(DEPOBJS:.ml=.opt) $(BIN_DIR)
+
+uninstall:
+ cd $(BIN_DIR)
+ rm -f $(DEPOBJS:.ml=) $(DEPOBJS:.ml=.opt)
+
+.PHONY: install uninstall clean
+
+ifneq ($(MAKECMDGOALS), depend)
+ include .depend
+endif
+
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+{
+ open MQGTopParser
+
+ let debug = false
+
+ let out s = if debug then prerr_endline s
+}
+
+let SPC = [' ' '\t' '\n']+
+let ALPHA = ['A'-'Z' 'a'-'z' '_']
+let NUM = ['0'-'9']
+let IDEN = ALPHA (NUM | ALPHA)*
+let QSTR = [^ '"' '\\']+
+
+rule comm_token = parse
+ | "(*" { comm_token lexbuf; comm_token lexbuf }
+ | "*)" { () }
+ | ['*' '('] { comm_token lexbuf }
+ | [^ '*' '(']* { comm_token lexbuf }
+and string_token = parse
+ | '"' { DQ }
+ | '\\' _ { STR (String.sub (Lexing.lexeme lexbuf) 1 1) }
+ | QSTR { STR (Lexing.lexeme lexbuf) }
+ | eof { EOF }
+and spec_token = parse
+ | "(*" { comm_token lexbuf; spec_token lexbuf }
+ | SPC { spec_token lexbuf }
+ | '"' { let str = qstr string_token lexbuf in
+ out ("STR " ^ str); STR str }
+ | '{' { out "LC"; LC }
+ | '}' { out "RC"; RC }
+ | ',' { out "CM"; CM }
+ | '$' { out "DL"; DL }
+ | "mustobj" { out "MOBJ" ; MOBJ }
+ | "mustsort" { out "MSORT" ; MSORT }
+ | "mustrel" { out "MREL" ; MREL }
+ | "onlyobj" { out "OOBJ" ; OOBJ }
+ | "onlysort" { out "OSORT" ; OSORT }
+ | "onlyrel" { out "OREL" ; OREL }
+ | "universe" { out "UNIV" ; UNIV }
+ | IDEN { let id = Lexing.lexeme lexbuf in
+ out ("ID " ^ id); ID id }
+ | eof { EOF }
--- /dev/null
+/* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ */
+
+/* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ */
+
+%{
+ let f (x, y, z) = x
+ let s (x, y, z) = y
+ let t (x, y, z) = z
+
+ module T = MQGTypes
+ module U = MQGUtil
+%}
+ %token <string> ID
+ %token <UriManager.uri> CONURI
+ %token <UriManager.uri> VARURI
+ %token <UriManager.uri * int> INDTYURI
+ %token <UriManager.uri * int * int> INDCONURI
+ %token ALIAS EOF
+
+ %start interp
+ %type <CicTextualParser0.interpretation_domain_item -> CicTextualParser0.interpretation_codomain_item option> interp
+
+ %token <string> STR
+ %token DL DQ LC RC CM
+ %token MOBJ MSORT MREL OOBJ OSORT OREL UNIV
+
+ %start qstr specs
+ %type <string> qstr
+ %type <MQGTypes.spec list> specs
+%%
+ uri:
+ | CONURI { CicTextualParser0.ConUri $1 }
+ | VARURI { CicTextualParser0.VarUri $1 }
+ | INDTYURI { CicTextualParser0.IndTyUri ((fst $1), (snd $1)) }
+ | INDCONURI { CicTextualParser0.IndConUri ((f $1), (s $1), (t $1)) }
+ ;
+ alias:
+ | ALIAS ID uri { ($2, CicTextualParser0.Uri $3) }
+ ;
+ aliases:
+ | alias aliases { $1 :: $2 }
+ | EOF { [] }
+ ;
+ interp:
+ | aliases { function CicTextualParser0.Id s -> (try Some (List.assoc s $1)
+ with Not_found -> None)
+ | _ -> None }
+ ;
+
+ qstr:
+ | DQ { "" }
+ | STR qstr { $1 ^ $2 }
+ ;
+ strs:
+ | STR CM strs { $1 :: $3 }
+ | STR { [$1] }
+ | { [] }
+ ;
+ uri_list:
+ | LC strs RC { List.map U.uri_of_mathql $2 }
+ ;
+ sort_list:
+ | LC strs RC { List.map U.sort_of_mathql $2 }
+ ;
+ pos_list:
+ | LC strs RC { List.map U.position_of_mathql $2 }
+ ;
+ depth_list:
+ | LC strs RC { List.map U.depth_of_mathql $2 }
+ ;
+ spec:
+ | MOBJ uri_list pos_list depth_list { T.MustObj ($2, $3, $4) }
+ | MSORT sort_list pos_list depth_list { T.MustSort ($2, $3, $4) }
+ | MREL pos_list depth_list { T.MustRel ($2, $3) }
+ | OOBJ uri_list pos_list depth_list { T.OnlyObj ($2, $3, $4) }
+ | OSORT sort_list pos_list depth_list { T.OnlySort ($2, $3, $4) }
+ | OREL pos_list depth_list { T.OnlyRel ($2, $3) }
+ | UNIV pos_list { T.Universe $2 }
+ ;
+ specs:
+ | spec specs { $1 :: $2 }
+ | EOF { [] }
+ ;
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+let query_num = ref 1
+
+let interp_file = ref "interp.cic"
+
+let log_file = ref ""
+
+let show_queries = ref false
+
+let int_options = ref ""
+
+let nl = " <p>\n"
+
+module U = MQueryUtil
+module I = MQueryInterpreter
+module C = MQIConn
+module G = MQueryGenerator
+module L = MQGTopLexer
+module P = MQGTopParser
+module TL = CicTextualLexer
+module TP = CicTextualParser
+module C3 = CGLocateInductive
+module C2 = CGSearchPattern
+module C1 = CGMatchConclusion
+module GU = MQGUtil
+
+let get_handle () =
+ C.init ~flags:(C.flags_of_string ! int_options)
+ ~log:(fun s -> print_string s; flush stdout) ()
+
+let issue handle q =
+ let mode = [Open_wronly; Open_append; Open_creat; Open_text] in
+ let perm = 64 * 6 + 8 * 6 + 4 in
+ let time () =
+ let lt = Unix.localtime (Unix.time ()) in
+ "NEW LOG: " ^
+ string_of_int (lt.Unix.tm_mon + 1) ^ "-" ^
+ string_of_int (lt.Unix.tm_mday + 1) ^ "-" ^
+ string_of_int (lt.Unix.tm_year + 1900) ^ " " ^
+ string_of_int (lt.Unix.tm_hour) ^ ":" ^
+ string_of_int (lt.Unix.tm_min) ^ ":" ^
+ string_of_int (lt.Unix.tm_sec)
+ in
+ let log q r =
+ let och = open_out_gen mode perm ! log_file in
+ let out = output_string och in
+ if ! query_num = 1 then out (time () ^ nl);
+ out ("Query: " ^ string_of_int ! query_num ^ nl);
+ U.text_of_query out nl q;
+ out ("Result: " ^ nl);
+ U.text_of_result out nl r;
+ close_out och
+ in
+ if ! show_queries then U.text_of_query (output_string stdout) nl q;
+ let r = I.execute handle q in
+ U.text_of_result (output_string stdout) nl r;
+ if ! log_file <> "" then log q r;
+ incr query_num;
+ flush stdout
+
+let get_interp () =
+ let lexer = function
+ | TP.ID s -> P.ID s
+ | TP.CONURI u -> P.CONURI u
+ | TP.VARURI u -> P.VARURI u
+ | TP.INDTYURI (u, p) -> P.INDTYURI (u, p)
+ | TP.INDCONURI (u, p, s) -> P.INDCONURI (u, p, s)
+ | TP.LETIN -> P.ALIAS
+ | TP.EOF -> P.EOF
+ | _ -> assert false
+ in
+ let ich = open_in ! interp_file in
+ let lexbuf = Lexing.from_channel ich in
+ let f = P.interp (fun x -> lexer (TL.token x)) lexbuf in
+ close_in ich; f
+
+let get_terms interp =
+ let interp = get_interp () in
+ let lexbuf = Lexing.from_channel stdin in
+ let rec aux () =
+ try
+ let dom, mk_term =
+ CicTextualParserContext.main [] [] CicTextualLexer.token lexbuf
+ in
+ (snd (mk_term interp)) :: aux ()
+ with
+ CicTextualParser0.Eof -> []
+ in
+ aux ()
+
+let pp_type_of uri =
+ let u = UriManager.uri_of_string uri in
+ let s = match (CicEnvironment.get_obj u) with
+ | Cic.Constant (_, _, ty, _) -> CicPp.ppterm ty
+ | Cic.Variable (_, _, ty, _) -> CicPp.ppterm ty
+ | _ -> "Current proof or inductive definition."
+(*
+ | Cic.CurrentProof (_,conjs,te,ty) ->
+ | C.InductiveDefinition _ ->
+*)
+ in print_endline s; flush stdout
+
+let rec display = function
+ | [] -> ()
+ | term :: tail ->
+ display tail;
+ print_string ("? " ^ CicPp.ppterm term ^ nl);
+ flush stdout
+
+let execute ich =
+ let lexbuf = Lexing.from_channel ich in
+ let handle = get_handle () in
+ let rec execute_aux () =
+ try
+ let q = U.query_of_text lexbuf in
+ issue handle q; execute_aux ()
+ with End_of_file -> ()
+ in
+ execute_aux ();
+ C.close handle
+
+let compose () =
+ let handle = get_handle () in
+ let cl = P.specs L.spec_token (Lexing.from_channel stdin) in
+ issue handle (G.compose cl);
+ C.close handle
+
+let locate name =
+ let handle = get_handle () in
+ issue handle (G.locate name);
+ C.close handle
+
+let unreferred target source =
+ let handle = get_handle () in
+ issue handle (G.unreferred target source);
+ C.close handle
+
+let mpattern n m l =
+ let queries = ref [] in
+ let univ = Some C2.universe in
+ let handle = get_handle () in
+ let rec pattern level = function
+ | [] -> ()
+ | term :: tail ->
+ pattern level tail;
+ print_string ("? " ^ CicPp.ppterm term ^ nl);
+ let t = U.start_time () in
+ let om,rm,sm = C2.get_constraints term in
+ let oml,rml,sml = List.length om, List.length rm, List.length sm in
+ let oo, ool = if level land 1 = 0 then None, 0 else Some om, oml in
+ let ro, rol = if level land 2 = 0 then None, 0 else Some rm, rml in
+ let so, sol = if level land 4 = 0 then None, 0 else Some sm, sml in
+ let q = G.query_of_constraints univ (om,rm,sm) (oo,ro,so) in
+ if not (List.mem q ! queries) then
+ begin
+ issue handle q;
+ Printf.eprintf "[%i] " (pred ! query_num); flush stderr;
+ Printf.printf "%i GEN = %i: %s"
+ (pred ! query_num) (oml + rml + sml + ool + rol + sol)
+ (U.stop_time t ^ nl);
+ flush stdout; queries := q :: ! queries
+ end
+ in
+ for level = max m n downto min m n do
+ Printf.eprintf "\nmqgtop: pattern: trying level %i\n" level;
+ flush stderr; pattern level l
+ done;
+ Printf.eprintf "\nmqgtop: pattern: %i queries issued\n"
+ (List.length ! queries);
+ flush stderr;
+ C.close handle
+
+let mbackward n m l =
+ let queries = ref [] in
+ let univ = Some C1.universe in
+ let handle = get_handle () in
+ let rec backward level = function
+ | [] -> ()
+ | term :: tail ->
+ backward level tail;
+ print_string ("? " ^ CicPp.ppterm term ^ nl);
+ let t = U.start_time () in
+ let list_of_must, only = C1.get_constraints [] [] term in
+ let max_level = pred (List.length list_of_must) in
+ let must = List.nth list_of_must (min level max_level) in
+ let q = G.query_of_constraints univ (must, [], []) (Some only , None, None) in
+ if not (List.mem q ! queries) then
+ begin
+ issue handle q;
+ Printf.eprintf "[%i] " (pred ! query_num); flush stderr;
+ Printf.printf "%i GEN = %i: %s"
+ (pred ! query_num) (List.length must)
+ (U.stop_time t ^ nl);
+ flush stdout; queries := q :: ! queries
+ end
+ in
+ for level = max m n downto min m n do
+ Printf.eprintf "\nmqgtop: backward: trying level %i\n" level;
+ flush stderr; backward level l
+ done;
+ Printf.eprintf "\nmqgtop: backward: %i queries issued\n"
+ (List.length ! queries);
+ flush stderr;
+ C.close handle
+
+let inductive l =
+ let queries = ref [] in
+ let univ = None in
+ let handle = get_handle () in
+ let rec aux = function
+ | [] -> ()
+ | term :: tail ->
+ aux tail;
+ print_string ("? " ^ CicPp.ppterm term ^ nl);
+ let t = U.start_time () in
+ let m = C3.get_constraints term in
+ let q = G.query_of_constraints univ m (None, None, None) in
+ if not (List.mem q ! queries) then
+ begin
+ issue handle q;
+ Printf.eprintf "[%i] " (pred ! query_num); flush stderr;
+ Printf.printf "%i GEN: %s"
+ (pred ! query_num) (U.stop_time t ^ nl);
+ flush stdout; queries := q :: ! queries
+ end
+ in
+ aux l;
+ Printf.eprintf "\nmqgtop: inductive: %i queries issued\n"
+ (List.length ! queries);
+ flush stderr;
+ C.close handle
+
+let check () =
+ let handle = get_handle () in
+ Printf.eprintf
+ "mqgtop: current options: %s, connection: %s\n"
+ ! int_options (if C.connected handle then "on" else "off");
+ C.close handle
+
+let prerr_help () =
+ prerr_endline "\nUSAGE: mqgtop.opt OPTIONS < INPUTFILE\n";
+ prerr_endline "The tool provides a textual interface to the HELM Query Generator, used for";
+ prerr_endline "testing purposes. mqgtop reads its input from stdin and produces ith output";
+ prerr_endline "in HTML on stdout. The options can be one ore more of the following.\n";
+ prerr_endline "OPTIONS:\n";
+ prerr_endline "-h -help shows this help message";
+ prerr_endline "-q -show-queries outputs generated queries";
+ prerr_endline "-l -log-file FILE sets the log file";
+ prerr_endline "-o -options STRING sets the interpreter options";
+ prerr_endline "-c -check checks the database connection";
+ prerr_endline "-t -typeof URI outputs the CIC type of the given HELM object";
+ prerr_endline "-x -execute issues a query given in the input file";
+ prerr_endline "-i -interp FILE sets the CIC short names interpretation file";
+ prerr_endline "-d -disply outputs the CIC terms given in the input file";
+ prerr_endline "-L -locate ALIAS issues the \"Locate\" query for the given alias";
+ prerr_endline "-U T_PATTERN S_PATTERN issues the \"Unreferred\" query for the given patterns";
+ prerr_endline "-C -compose issues the \"Compose\" query reading its specifications";
+ prerr_endline " from the input file";
+ prerr_endline "-B -backward LEVEL issues the \"Backward\" query for the given level on all";
+ prerr_endline " CIC terms in the input file";
+ prerr_endline "-MB -multi-backward MAX issues the \"Backward\" query for each level from max to 0";
+ prerr_endline " on all CIC terms in the input file";
+ prerr_endline "-P -pattern LEVEL issues the \"Pattern\" query for the given level on all";
+ prerr_endline " CIC terms in the input file";
+ prerr_endline "-MP -multi-pattern issues the \"Pattern\" query for each level from 7 to 0";
+ prerr_endline " on all CIC terms in the input file";
+ prerr_endline "-I issues the \"Inductive\" query on all CIC terms in the";
+ prerr_endline " input file\n";
+ prerr_endline "NOTES: * current interpreter options are:";
+ prerr_endline " P (postgres), G (Galax), S (show statistics), Q (quiet)";
+ prerr_endline " * CIC terms are read with the HELM CIC Textual Parser";
+ prerr_endline " * -typeof does not work with inductive types and proofs in progress\n"
+
+let rec parse = function
+ | [] -> ()
+ | ("-h"|"-help") :: rem -> prerr_help (); parse rem
+ | ("-i"|"-interp") :: arg :: rem -> interp_file := arg; parse rem
+ | ("-d"|"-display") :: rem -> display (get_terms ()); parse rem
+ | ("-t"|"-typeof") :: arg :: rem -> pp_type_of arg; parse rem
+ | ("-x"|"-execute") :: rem -> execute stdin; parse rem
+ | ("-q"|"-show-queries") :: rem -> show_queries := true; parse rem
+ | ("-o"|"-options") :: arg :: rem -> int_options := arg; parse rem
+ | ("-c"|"-check") :: rem -> check (); parse rem
+ | ("-l"|"-log-file") :: arg :: rem -> log_file := arg; parse rem
+ | ("-L"|"-Locate") :: arg :: rem -> locate arg; parse rem
+ | ("-C"|"-compose") :: rem -> compose (); parse rem
+ | ("-B"|"-backward") :: arg :: rem ->
+ let m = (int_of_string arg) in mbackward m m (get_terms ()); parse rem
+ | ("-MB"|"-multi-backward") :: arg :: rem ->
+ let m = (int_of_string arg) in mbackward m 0 (get_terms ()); parse rem
+ | ("-P"|"-pattern") :: arg :: rem ->
+ let m = (int_of_string arg) in mpattern m m (get_terms ()); parse rem
+ | ("-MP"|"-multi-pattern") :: rem -> mpattern 7 0 (get_terms ()); parse rem
+ | ("-U"|"-unreferred") :: arg1 :: arg2 :: rem ->
+ unreferred arg1 arg2; parse rem
+ | ("-I"|"-inductive") :: rem -> inductive (get_terms ()); parse rem
+ | _ :: rem -> parse rem
+
+let _ =
+ Helm_registry.load_from "/home/fguidi/miohelm/gTopLevel.conf.xml";
+ let t = U.start_time () in
+(*
+ CicLogger.log_callback :=
+ (CicLogger.log_to_html
+ ~print_and_flush:(fun s -> print_string s; flush stdout)) ;
+*)
+ parse (List.tl (Array.to_list Sys.argv));
+ prerr_endline ("mqgtop: done in " ^ (U.stop_time t));
+ exit 0
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+module U = MQueryUtil
+module I = MQueryInterpreter
+module C = MQIConn
+
+let _ =
+ Helm_registry.load_from "/home/fguidi/miohelm/gTopLevel.conf.xml";
+ let t = U.start_time () in
+ let ich = Lexing.from_channel stdin in
+ let flags = if Array.length Sys.argv >= 2 then Sys.argv.(1) else "" in
+ let log s = print_string s; flush stdout in
+ let handle = C.init ~flags:(C.flags_of_string flags) ~log:log () in
+ if not (C.connected handle) then begin
+ print_endline "mqitop: no connection"; flush stdout
+ end;
+ let rec aux () =
+ let t = U.start_time () in
+ let r = I.execute handle (U.query_of_text ich) in
+(* U.text_of_result log r "\n";
+*) Printf.printf "mqitop: query: %s,%i\n" (U.stop_time t) (List.length r);
+ flush stdout; aux()
+
+ in
+ begin try aux() with End_of_file -> () end;
+ C.close handle;
+ Printf.printf "mqitop: done: %s\n" (U.stop_time t)
--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+(* AUTOR: Ferruccio Guidi <fguidi@cs.unibo.it>
+ *)
+
+let _ =
+ let module U = MQueryUtil in
+ let t = U.start_time () in
+ let ich = Lexing.from_channel stdin in
+ let rec aux () =
+ let t = U.start_time () in
+ U.text_of_query print_string "\n" (U.query_of_text ich);
+ Printf.printf "mqtop: query: %s\n" (U.stop_time t);
+ flush stdout; aux()
+ in
+ begin try aux() with End_of_file -> () end;
+ Printf.printf "mqtop: done: %s\n" (U.stop_time t)
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!DOCTYPE MQLquery SYSTEM "xmathql.dtd">
+
+<!-- To validate: xmllint -valid -loaddtd -noout query.xml -->
+
+<MQLquery>
+ <Select>
+ <In>
+ <Relation name="Use">
+ <Pattern>
+ <CONST>cic:/Coq/Init/Logic/Equality/eq.ind</CONST>
+ </Pattern>
+ <Attr binder="$1"/>
+ </Relation>
+ </In>
+ <Where rvar="@result">
+ <AND>
+ <EQ>
+ <BINDER name="$1"><Rvar name="@result"/></BINDER>
+ <CONST>MainHypothesis</CONST>
+ </EQ>
+ <EQ>
+ <PROPERTY name="TITLE"><REFOF><Rvar name="@result"/></REFOF></PROPERTY>
+ <CONST>Uguaglianza</CONST>
+ </EQ>
+ </AND>
+ </Where>
+ </Select>
+</MQLquery>
+
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!DOCTYPE MQLresult SYSTEM "xmqlresult.dtd">
+
+<!-- To validate: xmllint -valid -loaddtd -noout result.xml -->
+
+<MQLresult>
+ <ResourceSet>
+ <RESOURCE name="cic:/Coq/Init/Logic/Equality/eq.ind">
+ <AttributeSet>
+ <ATTRIBUTE name="POSITION">
+ <CONST>MainHypothesis</CONST>
+ </ATTRIBUTE>
+ <ATTRIBUTE name="POSITION">
+ <CONST>InConclusion</CONST>
+ </ATTRIBUTE>
+ </AttributeSet>
+ </RESOURCE>
+ </ResourceSet>
+</MQLresult>
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- Copyright (C) 2000, HELM Team -->
+<!-- -->
+<!-- This file is part of HELM, an Hypertextual, Electronic -->
+<!-- Library of Mathematics, developed at the Computer Science -->
+<!-- Department, University of Bologna, Italy. -->
+<!-- -->
+<!-- HELM is free software; you can redistribute it and/or -->
+<!-- modify it under the terms of the GNU General Public License -->
+<!-- as published by the Free Software Foundation; either version 2 -->
+<!-- of the License, or (at your option) any later version. -->
+<!-- -->
+<!-- HELM is distributed in the hope that it will be useful, -->
+<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
+<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
+<!-- GNU General Public License for more details. -->
+<!-- -->
+<!-- You should have received a copy of the GNU General Public License -->
+<!-- along with HELM; if not, write to the Free Software -->
+<!-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, -->
+<!-- MA 02111-1307, USA. -->
+<!-- -->
+<!-- For details, see the HELM World-Wide-Web page, -->
+<!-- http://cs.unibo.it/helm/. -->
+
+<!--*****************************************************************-->
+<!-- DTD FOR the MATHEMATICAL QUERY MARKUP LANGUAGE (XMathQL) -->
+<!-- First draft: April 2002, Irene Schena -->
+<!-- Second draft: Agust 2002, Irene Schena -->
+<!--*****************************************************************-->
+
+<!--*****************************************************************-->
+<!-- This syntax is not convenient for humans to read and write, but -->
+<!-- it is for programs. -->
+<!-- XMathQL is useful for: -->
+<!-- 1) generating queries in a XML-orienting programming environment-->
+<!-- 2) embedding queries in XML documents -->
+<!-- 3) reusing queries saved in a standard format -->
+<!-- The syntax reflects the structure of the grammar productions of -->
+<!-- MathQL. -->
+<!-- Operators are unambiguous (binary or unary), so there isn't any -->
+<!-- grouping operator. -->
+<!-- CONST is the quoted constant string; rvar is for single -->
+<!-- reference and svar for sets of references, i.e. query results. -->
+<!-- The attributes binder, rvar, svar declare variables which are -->
+<!-- referred to and used by means of respectively BINDER, Rvar, Svar-->
+<!-- PROPERTY works on a specified RDF property returning its value. -->
+<!--*****************************************************************-->
+
+<!ENTITY % bool '(True|False)'>
+
+<!-- MathQL query expression declaration -->
+
+<!ENTITY % setexpr '(Rvar|Svar|Ref|Pattern|Select|LetSIn|LetVIn|Relation|
+ Union|Intersect|Diff)'>
+
+<!-- MathQL boolean expression declaration -->
+
+<!ENTITY % boolexpr '(BOOL|NOT|AND|OR|EQ|SUB|MEET|EX)'>
+
+<!-- MathQL string-set expression declaration -->
+
+<!ENTITY % functexpr '(FUN|PROPERTY)'>
+
+<!ENTITY % stringsetexpr '(CONST|CONSTLIST|REFOF|BINDER|VVAR|%functexpr;)'>
+
+<!-- MathQL query top-element -->
+
+<!ELEMENT MQLquery %setexpr;>
+
+<!-- MathQL set expressions -->
+
+<!ELEMENT Rvar EMPTY>
+<!ATTLIST Rvar
+ name CDATA #REQUIRED>
+
+<!ELEMENT Svar EMPTY>
+<!ATTLIST Svar
+ name CDATA #REQUIRED>
+
+<!ELEMENT Ref %stringsetexpr;>
+
+<!ELEMENT Pattern %stringsetexpr;>
+
+<!ELEMENT Select (In, Where)>
+
+<!ELEMENT LetSIn (%setexpr;, Starget)>
+
+<!ELEMENT LetVIn (%stringsetexpr;, Vtarget)>
+
+<!ELEMENT Relation (PName?,%setexpr;, Attr+)>
+<!ATTLIST Relation
+ name CDATA #REQUIRED
+ refine (sub|super) #IMPLIED>
+
+<!ELEMENT Union (%setexpr;, %setexpr;)>
+
+<!ELEMENT Intersect (%setexpr;, %setexpr;)>
+
+<!ELEMENT Diff (%setexpr;, %setexpr;)>
+
+<!-- MathQL set sub-expressions -->
+
+<!ELEMENT In %setexpr;>
+
+<!ELEMENT Where %boolexpr;>
+<!ATTLIST Where
+ rvar CDATA #REQUIRED>
+
+<!ELEMENT Starget %setexpr;>
+<!ATTLIST Starget
+ svar CDATA #REQUIRED>
+
+<!ELEMENT Vtarget %setexpr;>
+<!ATTLIST Vtarget
+ vvar CDATA #REQUIRED>
+
+<!ELEMENT Attr EMPTY>
+<!ATTLIST Attr
+ binder CDATA #REQUIRED>
+
+<!ELEMENT PName (CONST+)>
+
+<!-- MathQL boolean expressions -->
+
+<!ELEMENT BOOL EMPTY>
+<!ATTLIST BOOL
+ value %bool; #REQUIRED>
+
+<!ELEMENT NOT %boolexpr;>
+
+<!ELEMENT AND (%boolexpr;, %boolexpr;)>
+
+<!ELEMENT OR (%boolexpr;, %boolexpr;)>
+
+<!ELEMENT EQ (%stringsetexpr;, %stringsetexpr;)>
+
+<!ELEMENT SUB (%stringsetexpr;, %stringsetexpr;)>
+
+<!ELEMENT MEET (%stringsetexpr;, %stringsetexpr;)>
+
+<!ELEMENT EX %boolexpr;>
+
+<!-- MathQL string-set expressions -->
+
+<!ELEMENT CONST (#PCDATA)>
+
+<!ELEMENT CONSTLIST (CONST*)>
+
+<!ELEMENT REFOF %setexpr;>
+
+<!ELEMENT VVAR %stringsetexpr;>
+
+<!ELEMENT BINDER (Rvar)>
+<!ATTLIST BINDER
+ name CDATA #REQUIRED>
+
+<!ELEMENT FUN %stringsetexpr;>
+<!ATTLIST FUN
+ name CDATA #REQUIRED>
+
+<!ELEMENT PROPERTY (Refine?,%stringsetexpr;)>
+<!ATTLIST PROPERTY
+ name CDATA #REQUIRED>
--- /dev/null
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!-- Copyright (C) 2000, HELM Team -->
+<!-- -->
+<!-- This file is part of HELM, an Hypertextual, Electronic -->
+<!-- Library of Mathematics, developed at the Computer Science -->
+<!-- Department, University of Bologna, Italy. -->
+<!-- -->
+<!-- HELM is free software; you can redistribute it and/or -->
+<!-- modify it under the terms of the GNU General Public License -->
+<!-- as published by the Free Software Foundation; either version 2 -->
+<!-- of the License, or (at your option) any later version. -->
+<!-- -->
+<!-- HELM is distributed in the hope that it will be useful, -->
+<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of -->
+<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -->
+<!-- GNU General Public License for more details. -->
+<!-- -->
+<!-- You should have received a copy of the GNU General Public License -->
+<!-- along with HELM; if not, write to the Free Software -->
+<!-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, -->
+<!-- MA 02111-1307, USA. -->
+<!-- -->
+<!-- For details, see the HELM World-Wide-Web page, -->
+<!-- http://cs.unibo.it/helm/. -->
+
+<!--*****************************************************************-->
+<!-- DTD for RESULTS of XMathQL queries -->
+<!-- First draft: September 2002, Irene Schena -->
+<!--*****************************************************************-->
+
+
+<!-- MQL result expression declaration -->
+
+<!ENTITY % resultexpr '(ResourceSet)'>
+
+
+<!-- MQL result top-element -->
+
+<!ELEMENT MQLresult %resultexpr;>
+
+<!-- Result expressions and sub-expressions -->
+
+<!ELEMENT ResourceSet (RESOURCE*)>
+
+<!ELEMENT RESOURCE (AttributeSet*)>
+<!ATTLIST RESOURCE
+ name CDATA #REQUIRED>
+
+<!ELEMENT AttributeSet (ATTRIBUTE+)>
+
+<!ELEMENT ATTRIBUTE (CONST*)>
+<!ATTLIST ATTRIBUTE
+ name CDATA #REQUIRED>
+
+<!-- MQL result string expressions -->
+
+<!ELEMENT CONST (#PCDATA)>
+