flora-commits Mailing List for Flora-2
Brought to you by:
kifer
You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(59) |
Jun
(43) |
Jul
(4) |
Aug
(4) |
Sep
(102) |
Oct
(20) |
Nov
(47) |
Dec
(32) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(24) |
Feb
(34) |
Mar
(72) |
Apr
(36) |
May
(10) |
Jun
(46) |
Jul
(36) |
Aug
(24) |
Sep
(37) |
Oct
(27) |
Nov
(43) |
Dec
(40) |
| 2004 |
Jan
(35) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(30) |
Aug
(83) |
Sep
(68) |
Oct
(38) |
Nov
(3) |
Dec
(7) |
| 2005 |
Jan
(9) |
Feb
(31) |
Mar
(46) |
Apr
(73) |
May
(21) |
Jun
(1) |
Jul
(32) |
Aug
(33) |
Sep
(3) |
Oct
(28) |
Nov
(4) |
Dec
(23) |
| 2006 |
Jan
(22) |
Feb
(2) |
Mar
(12) |
Apr
(23) |
May
(73) |
Jun
(14) |
Jul
|
Aug
(20) |
Sep
(14) |
Oct
(5) |
Nov
|
Dec
(14) |
| 2007 |
Jan
(54) |
Feb
(81) |
Mar
(286) |
Apr
(313) |
May
(154) |
Jun
(85) |
Jul
(8) |
Aug
(11) |
Sep
(12) |
Oct
(14) |
Nov
(6) |
Dec
(6) |
| 2008 |
Jan
|
Feb
|
Mar
(1) |
Apr
(12) |
May
(4) |
Jun
|
Jul
(13) |
Aug
(22) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(46) |
Jun
(43) |
Jul
(46) |
Aug
(9) |
Sep
(13) |
Oct
(31) |
Nov
(42) |
Dec
(18) |
| 2014 |
Jan
(7) |
Feb
(7) |
Mar
(11) |
Apr
(13) |
May
(16) |
Jun
(6) |
Jul
(17) |
Aug
|
Sep
(2) |
Oct
|
Nov
(1) |
Dec
|
| 2015 |
Jan
|
Feb
(17) |
Mar
(4) |
Apr
(3) |
May
(2) |
Jun
(3) |
Jul
(2) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
| 2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
| 2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
|
|
1
(4) |
2
|
3
|
4
|
5
|
|
6
(4) |
7
|
8
(1) |
9
|
10
|
11
|
12
(2) |
|
13
(7) |
14
(3) |
15
|
16
|
17
|
18
(2) |
19
|
|
20
(1) |
21
(9) |
22
(6) |
23
|
24
(4) |
25
|
26
(3) |
|
27
|
28
|
29
|
30
|
31
|
|
|
|
From: Michael K. <ki...@us...> - 2005-03-26 10:27:11
|
Update of /cvsroot/flora/flora2/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27833/docs Modified Files: flora2.tex Log Message: moved sections to more logical places Index: flora2.tex =================================================================== RCS file: /cvsroot/flora/flora2/docs/flora2.tex,v retrieving revision 1.127 retrieving revision 1.128 diff -u -d -r1.127 -r1.128 --- flora2.tex 26 Mar 2005 04:28:38 -0000 1.127 +++ flora2.tex 26 Mar 2005 10:26:59 -0000 1.128 @@ -1696,6 +1696,472 @@ +\section{Path Expressions}\label{sec-pathexpr} + +\subsection{Path Expressions in the Rule Body} + + +\index{path expression} \index{path expression!in rule body} +%% +In addition to the basic \fl syntax, the \FLORA system also supports [...2020 lines suppressed...] +flight objects into the members of that class. +While it solves the problem, this approach might not always be acceptable, +since the oid essentially explicitly encodes all the information in the tuple. + +An alternative approach is to use the {\tt newoid\{...\}} primitive from +Section~\ref{sec-anon-gen-oids}. Here we are using the fact that each time +{\tt flight(F,T)} is satisfied, {\tt newoid\{X\}} generates a new value for +{\tt X}. +%% +\begin{verbatim} + O:flight[from->F, to->T] :- newoid{O}, flight(F,T). +\end{verbatim} +%% +This approach is not as declarative as the first one, but it saves the user +from the need to figure out how exactly the oids in the rule head should be +constructed. + \section{Miscellaneous Features} |
|
From: Michael K. <ki...@us...> - 2005-03-26 10:26:39
|
Update of /cvsroot/flora/flora2/syslib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27618/syslib Modified Files: flrnewoid.P Log Message: bug fix Index: flrnewoid.P =================================================================== RCS file: /cvsroot/flora/flora2/syslib/flrnewoid.P,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- flrnewoid.P 17 Jun 2004 22:46:41 -0000 1.1 +++ flrnewoid.P 26 Mar 2005 10:26:30 -0000 1.2 @@ -34,4 +34,7 @@ %% May need to be more sophisticated here FLLIBNEWOID(NewOid) :- + var(NewOid), + !, gensym(FL_NEWOID_DYNPREFIX,NewOid). +FLLIBNEWOID(NewOid). |
|
From: Michael K. <ki...@us...> - 2005-03-26 04:28:48
|
Update of /cvsroot/flora/flora2/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29989/docs Modified Files: flora2.tex Log Message: cleanup Index: flora2.tex =================================================================== RCS file: /cvsroot/flora/flora2/docs/flora2.tex,v retrieving revision 1.126 retrieving revision 1.127 diff -u -d -r1.126 -r1.127 --- flora2.tex 22 Mar 2005 06:20:56 -0000 1.126 +++ flora2.tex 26 Mar 2005 04:28:38 -0000 1.127 @@ -3284,11 +3284,10 @@ group(X)}. Variables in HiLog can range over terms, predicate and function symbols, and even over atomic formulas. However, when a variable appears as a predicate symbol, it has to be prefixed with -``\verb|!|'' or ``\verb|#|'' to indicate whether the HiLog predicate is -tabled or not, respectively. We will always assume that tabled HiLog -predicates are intended and thus use the ``\verb|!|'' prefix for such -variables until Section~\ref{sec-tabling-flora} which discusses tabling -in \FLORA. +``\verb|!|'' or ``\verb|#|'' to indicate whether the predicate is +supposed to be tabled (!) or not (\#). In most of our examples, we will +use tabled HiLog +predicates and thus use the prefix ``\verb|!|''. For instance, %% @@ -3303,7 +3302,7 @@ %% \begin{equation}\label{eq-hilog-notallowed} {\tt - ?- p(X), ~!X(p), ~X. + ?- p(X), ~!X(p), ~\#X(q). } \end{equation} %% @@ -3312,6 +3311,16 @@ a(b)} are all true in the database, then $\tt X=a(b)$ is one of the answers to the query in HiLog. +Note that if {\tt X}, {\tt !X}, and {\tt \#X} all appear in the same rule, +such as above, then they get bound to \emph{the same} value. +The prefix +affects only the question of whether tabled or untabled predicates are +going to be used with each particular occurrence of the variable. +For instance, if {\tt X} is bound to {\tt a(b)}, then {\tt !X(p)} will be +true if the tabled predicate {\tt a(b)(p)} is true. At the same time, +{\tt \#X(p)} will be true if the non-tabled predicate {\tt \#a(b)(p)} is +true. + \index{HiLog!translation} % Although HiLog has a higher order syntax, its semantics is first order @@ -3545,38 +3554,6 @@ {\tt (a[b->c]@foo)@N)} at run time and, due to the scoping rules, is the same as {\tt a[b->c]@foo}. -%% One more thing to know about meta-unification is that it is done at -%% the predicate level; the arguments of the predicates involved in a -%% meta-unification operation are not meta-unified. -%% Thus the following query will fail because although {\tt p@M} and -%% {\tt p@foo} meta-unify, they do not unify in the regular sense. -%% %% -%% \begin{quote} -%% \begin{verbatim} -%% ?- X ~ p@M, Y ~ p@foo, pp(X) ~ pp(Y). -%% \end{verbatim} -%% \end{quote} -%% %% -%% If the user wants meta-unification for the argument in the above -%% example, she can reify the arguments (see the next section). For instance, -%% the following query succeeds. -%% %% -%% \begin{quote} -%% \begin{verbatim} -%% ?- X ~ p@M, Y ~ p@foo, pp(${X@_M1}) ~ pp(${Y@_M2}). -%% \end{verbatim} -%% \end{quote} -%% %% -%% Notice that the following query still fails because reification does not -%% have any effect if the reified formula is a variable and therefore the -%% query is the same as the one without reification. -%% %% -%% \begin{quote} -%% \begin{verbatim} -%% ?- X ~ p@M, Y ~ p@foo, pp(${X}) ~ pp(${Y}). -%% \end{verbatim} -%% \end{quote} -%% %% \subsection{Reification} @@ -3960,8 +3937,44 @@ \end{quote} %% +Nonmonotonicity also arises due to multiple inheritance. The following +example, known as the Nixon Diamond, illustrates the problem. Let us assume +the following knowledge base: +%% +\begin{verbatim} + republican[policy *-> nonpacifist]. + quaker[policy *-> pacifist]. + nixon:quaker. +\end{verbatim} +%% +Since Nixon is a Quaker, we can derive {\tt nixon[policy -> pacifist]} +by inheritance from the second clause. Let us now assume that the following +information is added: +%% +\begin{verbatim} + nixon:republican. +\end{verbatim} +%% +Now we have a conflict. There are two conflicting inheritance candidates: +{\tt policy *-> pacifist} and {\tt policy *-> nonpacifist}. +In \FLORA, such conflicts cause previously established inheritance +to be withdrawn and the value of the attribute {\tt policy} becomes +undefined for object {\tt nixon}.\footnote{ + %% + This behavior can be altered by adding additional rules. For instance, + one could define a predicate {\tt hasPriority} and then define + %% + \begin{quote} + \tt + Obj[policy->P] :- Obj:Class, Class[policy*->P], not hasPriority(AnotherClass,Class). + \end{quote} + %% + %% +} +%% + Behavioral inheritance in \fl is discussed at length in -\cite{inheritance-odbase-02}. The above problem of non-monotonicity is +\cite{inheritance-odbase-02}. The above non-monotonic behavior is just the tip of an iceberg. Much more difficult problems arise when inheritance interacts with regular deduction. To illustrate, consider the following program: @@ -4018,13 +4031,13 @@ different, more cautious semantics for inheritance, which favors the first interpretation above. -The details of this semantics are described in +Details of this semantics are formally described in \cite{inheritance-odbase-02}. Under this semantics, {\tt clyde} will still inherit color white, but in the other two examples {\tt a[m->c]} is \emph{not} inherited. The basic intuition can be summarized as follows: %% \begin{enumerate} -\item Methods definitions in subclasses override the definitions that +\item Method definitions in subclasses override the definitions that appear in the superclasses. \item In case of a multiple inheritance conflict, the result of inheritance is undefined. More precisely, \FLORA is based on a three-valued logic and @@ -4038,8 +4051,8 @@ \end{verbatim} %% Even though we derive {\tt c[m*->f]} and {\tt d[m*->f]} by inheritance, - these two facts can be further inherited to {\tt a} since they came from - a single source {\tt e}. + these two facts can be further inherited to the object {\tt a}, since + they came from a single source {\tt e}. On the other hand, in a similar program %% @@ -4875,6 +4888,188 @@ %% +\section{Negation} \label{sec:negation} + + +\index{negation as failure} +\index{well-founded semantics for negation} +%% +\FLORA supports two kinds of negation: the usual Prolog's \emph{negation as + failure} \cite{Cla78} and negation based on \emph{well-founded semantics} +\cite{gelder-alternating-89,gelder-ross-schlipf-91}. Both types of negation +are compiled into clauses that invoke the corresponding operators in +Prolog. + +We should remark that originally, the term ``negation +as failure'' was used to denote the treatment of negation in Prolog. This +style of negation is unsatisfactory in many respects because it does not +have a model-theoretic characterization and because operationally it often +leads to infinite loops. To overcome this problem, several different +semantics were introduced, including the aforesaid well-founded semantics. +At some point later, the meaning of the term negation as failure was +broadened to refer to the class of all these forms of negation. +When ambiguity may arise, we will be referring to \emph{Prolog-style + negation as failure}. + +\subsection{Two Operators for Negation}\label{sec-negation} +\index{\TNOT} +\index{\NAF} +%% +Prolog-style negation as failure is specified using the operator \NAF. +Negation based on the well-founded semantics is specified using the +operator \TNOT. The well-founded negation, \TNOT, applies to predicates +that are tabled (i.e., predicates that do not have the {\tt \#} prefix) or +to F-molecules that do not contain procedural methods (i.e., methods that +are prefixed with a {\tt \#}). + +The semantics for negation as failure is simple. To find out whether {\tt + \NAF G} is true, the system first asks the query {\tt ?- G}. If the query +succeeds then {\tt \NAF G} is said to be satisfied. Unfortunately, this +semantics is problematic. It cannot be characterized model-theoretically +and in certain simple cases the procedure for testing whether {\tt \NAF G} +holds may send the system into an infinite loop. For instance, in the +presence of the rule {\tt \#p :- \NAF \#p}, the query {\tt ?- \#p} will not +terminate. Negation as failure is the recommended kind of negation for +non-tabled predicates (but caution needs to be exercised). + +The well-founded negation, \TNOT, has a model-theoretic semantics and is +much more +satisfactory from the logical point of view. +Formally, this semantics uses three-valued models where formulas can be +true, false, or undefined. For instance, if our program has the rule +{\tt p :- \TNOT p} then the truth value of {\tt p} is \emph{undefined}. +Although the details of this +semantics are somewhat involved \cite{gelder-ross-schlipf-91}, it is +usually not necessary to know them, because this type of negation yields +the results that the user normally expects. The implementation of +the well-founded negation in XSB requires that it is applied to goals that +consist entirely of tabled predicates or molecules. +Although \FLORA allows \TNOT to be applied to non-tabled goals, +this may lead to unexpected results. For instance, +Section~\ref{sec-updates} discusses what might happen if the +negated formula is defined in terms of an update primitive. + +For more information on the implementation of the negation operators in XSB +we refer the reader to the XSB manual. + +Both \NAF and \TNOT can be used as operators inside and outside \FLORA +molecules. For instance, +%% +\begin{alltt} + flora2 ?- \TNOT #p(a). + flora2 ?- \NAF #p(a). + flora2 ?- \TNOT X[foo->bar, bar->>foo]. + flora2 ?- X[\TNOT foo->bar, bar->>foo, \NAF #p(Y)]. +\end{alltt} +%% +are all legal queries. Note that \NAF applies only to non-tabled +constructs, such as non-tabled \FLORA predicates and procedural methods. + +We should warn against one pitfall however. Sometimes it is necessary to +apply negation to several separate literals and write something like +%% +\begin{alltt} + flora2 ?- \NAF(#p(a),#q(X)). + flora2 ?- \TNOT(p(a),q(X)). + flora2 ?- \TNOT(X[foo->bar], X[bar->>foo]). +\end{alltt} +%% +This is incorrect however, since in this context \FLORA (and Prolog as +well) will interpret \TNOT and \NAF as predicates with two arguments, +which are likely to be undefined. The correct syntax is: +%% +\begin{alltt} + flora2 ?- \NAF((#p(a),#q(X))). + flora2 ?- \TNOT((#p(a),#q(X))). + flora2 ?- \TNOT((X[foo->bar], X[bar->>foo])). +\end{alltt} +%% +{\it i.e.}, an additional pair of parentheses is needed to indicate that +the sequence of literals form a single argument. + +\subsection{True vs. Undefined Literals} + +The fact that the well-founded semantics for negation is three-valued +brings up the question of what exactly does the success or failure of a +call means. Is undefinedness covered by a success or by failure? The way +this is implemented in XSB is such that a call to a literal, $P$, succeeds +if and only if $P$ is true \emph{or} undefined. Therefore, it is sometimes +necessary to be able to separate true and undefined facts. In \FLORA, this +separation is accomplished by a call to the {\tt get\_residual/2} +predicate, which is provided by XSB. A call to +%% +\index{get\_residual/2} +%% +\begin{verbatim} + get_residual(Call,List)@prolog(tables) +\end{verbatim} +%% +succeeds if and only if {\tt Call} is either true or undefined according to +the well-founded semantics. Moreover, {\tt Call} is true iff {\tt List} is +nil ({\it i.e.}, {\tt []}). Thus, {\tt get\_residual(Call,[])@prolog(tables)} +succeeds if and only if {\tt Call} is true. + +\subsection{Unbound Variables in Negated Goals} + +When negation (either \NAF or \TNOT) is applied to a non-ground goal, one +should be aware of the following peculiarity. Consider {\tt \NAF Goal}, +where Goal has variables that are not bound. As mentioned before, +{\tt \NAF GOAL} is evaluated by posing {\tt Goal} as a query. If for +\emph{some} values of for the variables in {\tt Goal} the query succeeds, +then {\tt \NAF Goal} is false; it is true only if for \emph{all} possible +substitutions for the variables in {\tt Goal} the query is false +(fails). Therefore {\tt \NAF Goal} intuitively means $\tt\forall +Vars\,\neg\,Goal$, where {\tt Vars} represents all the nonbound variables +in {\tt Goal}. The well-founded negation has the same flavor: if {\tt + Goal} is non-ground then {\tt \TNOT GOAL} means $\tt\forall +Vars\,\neg\,Goal$. + +Of course, one should keep in mind that since neither {\tt \NAF} nor {\tt + \TNOT} is a classical negation, none of the above formulas is actually +equivalent to $\tt\forall Vars\,\neg\,Goal$, if $\neg$ is understood as +classical negation. A more precise meaning is that {\tt \TNOT Goal} is true +if and only if for every ground instance {\tt Goal$'$} of +{\tt Goal}, the literal {\tt \TNOT Goal$'$} is true in +the well-founded semantics. +Similarly, {\tt \NAF Goal} evaluates to true if and +only if for every ground instance {\tt Goal$'$} of {\tt Goal}, the query +{\tt \NAF Goal$'$} succeeds according to the negation-as-failure +semantics. + +To illustrate this, consider the following example: +%% +\begin{verbatim} + p(a,b). + q(X,Y) :- not p(X,Y). + flora ?- q(X,Y). +\end{verbatim} +%% +When {\tt not p(X,Y)} is called in the query evaluation process, the variables +are unbound, so for the query to return a positive answer, the literal {\tt + p(t,s)} should be false for every possible terms {\tt t} and {\tt s}. +Since {\tt p(a,b)} is true, our query {\tt q(X,Y)} fails. In contrast, the +query +%% +\begin{verbatim} + flora2 ?- q(b,Y). +\end{verbatim} +%% +will succeed because this will cause the query {\tt not p(b,Y)} to be +evaluated. But this query will return positive answer because {\tt p(b,Y)} +is false for all {\tt Y}. Note that even when the query succeeds the +unbound variable that occurs in the scope of the negation operator remains +unbound: +%% +\begin{verbatim} + flora2 ?- not p(b,Y). + + Y = _h1747 + + 1 solution(s) in 0.0000 seconds on speedy.foo.org +\end{verbatim} +%% + + \section{\FLORA and Tabling}\label{sec-tabling-flora} @@ -4911,13 +5106,14 @@ A predicate with the \verb|#| prefix is logically unrelated to the predicate without the \verb|#| prefix. Thus, {\tt p(a)(b)} being true does -not mean that {\tt \verb|#|p(a)(b)} is true, and vice versa. +not imply anything about {\tt \verb|#|p(a)(b)}, and vice versa. -When the predicate name is a variable, it is not clear whether the user -means tabled or non-tabled predicate. For this reason, we introduce -variables prefixed with the ``\verb|!|'' sign for tabled predicates as a -counterpart for variables prefixed with ``\verb|#|''. Therefore the -following are legal +When the predicate name is a variable, it is not possible to determine +whether the user intended it to be a tabled or a non-tabled predicate. For +this reason, \FLORA requires that the user must attach a prefix ``\verb|!|'' +to variables that stand for tabled predicates and prefix ``\verb|#|'' for +variables that stand for non-tabled predicates. Therefore the following +statements are legal %% \begin{quote} \begin{verbatim} @@ -4933,7 +5129,7 @@ \begin{quote} \begin{verbatim} ?- X(a). // ambiguity -?- !p(a). // ! is only allowed before variables +?- !p(a). // prefix ! is allowed only with variables \end{verbatim} \end{quote} %% @@ -4945,11 +5141,11 @@ %% \begin{quote} \begin{verbatim} -?- insert{#p(a)}, #_(X), !X(Y). // #_ is a variable. #_ and !X are predicate names +?- insert{#p(a)}, #_(X), !X(Y). // #_, !X - variables ranging over predicate names ?- a[#b(c)], a[#Y]. // #b and #Y are procedural Boolean methods -?- #X ~ #p(a). // #X is a variable, #p is a non-tabled predicate +?- #X ~ #p(a). // #X is a variable, #p - a non-tabled predicate ?- !X ~ p(a). // !X is a variable -?- a[!Y]. // !Y is a Boolean method +?- a[!Y]. // !Y is a variable ranging over Boolean methods \end{verbatim} \end{quote} %% @@ -4966,23 +5162,23 @@ \end{quote} %% The first formula is illegal because {\tt \#a} occurs as a term and not -as a predicate (it can be made legal by reification, however: {\tt +as a predicate (it can be made legal by reifying the argument: {\tt p(\$\{\#a\})}). In the second, third and fourth formulas {\tt \#a}, {\tt -\#X} and {\tt !X} likewise appear as unreified terms. The fifth -formula is illegal because {\tt \#b(c)} is not a Boolean method. The -last formula is illegal because variables prefixed with ``\verb|!|'' are -not allowed as methods. +\#X} and {\tt !X} also appear as unreified arguments. The last +formula is illegal because {\tt \#b(c)} is not a Boolean method. Occurrences of variables that are prefixed with {\tt \#} or {\tt !} are -treated specially. First, it should be kept in mind that {\tt \#X}, -{\tt !X} and {\tt X} represent the same variable. If {\tt X} is -\emph{already bound} to something then all three of them mean the same -thing. However, {\tt X} can range over not only predicates but also -terms, conjunction of predicates, and even rules. {\tt \#X} can be -bound to only non-tabled predicates and {\tt !X} can be bound to only -tabled predicates. Thus error messages ``non-tabled predicate -expected'' and ``tabled predicate expected'' are issued for the -following two queries, respectively. +treated specially. First, it should be kept in mind that {\tt \#X}, {\tt + !X} and {\tt X} represent the same variable. If {\tt X} is \emph{already + bound} to something then all three of them mean the same thing. However, +when {\tt X}, {\tt \#X}, or {\tt !X} appear as terms by themselves, +{\tt X} can range not only over predicates but also terms, +conjunctions/disjunctions of predicates, and even rules. In contrast, +{\tt \#X} can be +bound only to non-tabled formulas and {\tt !X} can be bound only to +tabled formulas. Thus error messages ``non-tabled predicate expected'' +and ``tabled predicate expected'' will be issued for the following two +queries: %% \begin{quote} \begin{verbatim} @@ -4991,10 +5187,10 @@ \end{verbatim} \end{quote} %% -The following queries fail for the reason that {\tt \#X}, {\tt !X} and -{\tt X} represent the same variable: in each case the first literal -determines the binding for {\tt X}, and this binding does not match with -the expression on the right side of $\sim$ in the second literal. +The following queries fail because {\tt \#X}, {\tt !X} and +{\tt X} represent the same variable: in each case the first conjunct +determines the binding for {\tt X}, and this binding does not match +the expression on the right side of $\sim$ in the second conjunct. %% \begin{quote} \begin{verbatim} @@ -5004,27 +5200,33 @@ \end{verbatim} \end{quote} %% +For instance, in the first query, {\tt X} is bound to the non-tabled +formula {\tt \#p(a)}, and this does not meta-unify with the tabled formula +{\tt p(a)}. In the second query, {\tt X} is bound to the tabled +\emph{formula} {\tt p(a)}, and this does not unify with the plain HiLog +term {\tt p(a)}. In the third case, {\tt X} is bound to the tabled formula +{\tt p(a)}, but this does not meta-unify with the non-tabled formula {\tt + \#p(a)}. When a bound variable occurs with an explicit module specification, then the following rules apply: %% \begin{itemize} - \item If {\tt X} or {\tt \#X} or {\tt !X} is bound to a predicate or - molecule formula (tabled or non-tabled), then {\tt X@module} has the - same meaning as {\tt X}, and similarly for {\tt \#X} and {\tt - !X}. That is, if the binding is already a formula (and thus its - module is already specified in it) then the additional explicit module - specification is discarded. +\item If {\tt X} or {\tt \#X} or {\tt !X} is bound to a predicate or + molecular formula (tabled or non-tabled), then {\tt X@module} has the + same meaning as {\tt X}, and similarly for {\tt \#X} and {\tt !X}. That + is, if the binding is already a formula (and thus its module is already + specified in it) then the explicit module specification is discarded. \item If {\tt !X} or {\tt \#X} is bound to a HiLog \emph{term} (not a predicate), e.g., {\tt p(a)(Z)}, then {\tt !X@module} represents the tabled predicate {\tt p(a)(Z)@module}. Similarly, {\tt \#X@module} represents the non-tabled predicate {\tt \#p(a)(Z)@module}. {\tt X@module} will - give an error because it is not clear whether the tabled or non-tabled + cause an error because it is not clear whether the tabled or non-tabled predicate is intended. \end{itemize} %% Due to these rules, the first query below succeeds, while the second -fails and the third gives an error. +fails and the third causes an error. %% \begin{verbatim} flora2 ?- X = p(a), #X@M ~ #p(a), !X@N ~ p(a)@foo. @@ -5032,16 +5234,17 @@ flora2 ?- X = p(a), X@M ~ p(a)@foo. \end{verbatim} %% -The first query succeeds because {\tt X} is bound to a term, which {\tt - \#X@M} converts to a non-tabled predicate with yet-to-be-determined - module. The meta-unification that follows therefore binds {\tt M} to - {\tt main}. Similarly {\tt !X@N} converts the term to a tabled - predicate and the meta-unification binds {\tt N} to {\tt foo}. The +The first query succeeds because {\tt X} is bound to the term {\tt p(a)}, +which {\tt \#X@M} promotes to a non-tabled predicate with yet-to-be-determined +module. The meta-unification that follows then binds {\tt M} to +{\tt main}. Similarly {\tt !X@N} promotes the term {\tt p(a)} to a tabled + predicate with a yet-to-be-determined module, + and meta-unification binds {\tt N} to {\tt foo}. The second query fails because {\tt X} is already bound to a tabled predicate and therefore {\tt !X@M} represents {\tt p(a)@main}, which does not meta-unify with {\tt p(a)@foo}. The third query gives an - error because {\tt X@M} does not specify to convert the term to a - tabled predicate or a non-tabled one. + error because {\tt X@M} is ambiguous: it is not clear whether the term + {\tt p(a)} should be promoted to a tabled or a non-tabled formula. When {\tt !X} (and thus {\tt \#X}) is \emph{unbound} then the occurrences of {\tt \#X} indicate that {\tt X} is expected to be bound @@ -5074,8 +5277,9 @@ or method and {\tt \verb|!|X} expects to be meta-unified only with a tabled predicate or method. -Unbound {\tt X} can meta-unify with both tabled and non-tabled -predicates. Therefore the following queries all succeed. +Unbound and unprefixed variable such as {\tt X} can meta-unify with both +tabled and non-tabled predicates. Therefore the following queries all +succeed. %% \begin{quote} @@ -5090,23 +5294,24 @@ \end{quote} %% -In the context of update operations, we have the same rules: {\tt \#X} - for non-tabled predicates, {\tt !X} for tabled predicates and {\tt X} - for both. The following example shows this. +In the context of update operations, \FLORA uses the same rules: {\tt \#X} + binds to non-tabled predicates, {\tt !X} to tabled predicates and {\tt X} + to both. The following example illustrates this. %% \begin{quote} \begin{verbatim} -?- insert{p(a),#q(b)}. //Yes -?- delete{!X}. //Yes with X = ${p(a)} -?- delete{#X}. //Yes with X = ${#q(b)} -?- insert{p(a),#q(b)}. //Yes -?- delete{X}. //Yes with X non-determinstically bound to ${p(a)} or ${#q(b)} +?- insert{p(a),#q(b)}. // Yes +?- delete{!X}. // Yes, with X is bound ${p(a)} +?- delete{#X}. // Yes, with X is bound ${#q(b)} +?- insert{p(a),#q(b)}. // Yes +?- delete{X}. // Yes, X is bound to ${p(a)} or ${#q(b)} \end{verbatim} \end{quote} %% -These rules also apply to querying rule bases with {\tt clause} or -deleting rules with {\tt deleterule}. +These rules also apply to queries issued against rule bases using +the {\tt clause} primitive or to deletion of rules with the {\tt deleterule} +primitive. %% \begin{quote} @@ -5114,25 +5319,28 @@ ?- insertrule{p(X) :- q(X)}. ?- insertrule{#t(X) :- #r(X)}. ?- insertrule{pp(X) :- q(X), #r(X)}. -?- clause{X,Y}. // all three rules match +?- clause{X,Y}. // all three inserted rules above would be retrieved ?- clause{#X,Y}. // X = #t(_var) and Y = #r(_var) ?- clause{!X,!Y}. // X = p(_var) and Y = q(_var) -?- clause{!X,Y}. // the first and third match +?- clause{!X,Y}. // the first and the third rules would be retrieved \end{verbatim} \end{quote} %% -For reified formulas that appear as predicate arguments, \FLORA uses -{\tt \$\{!X\}} to denote tabled predicates, {\tt \$\{\verb|#|X\}} to -denote non-tabled predicates, and {\tt \$\{X\}} or simply a variable -{\tt X} to unify with anything. +For reified formulas that appear as arguments to predicates, \FLORA uses +{\tt \$\{!X\}} to ensure that {\tt X} unifies only with tabled reified +formulas and {\tt \$\{\verb|#|X\}} to +force {\tt X} to unify only with non-tabled formulas. +{\tt \$\{X\}} is not allowed. Instead, +one should use plain {\tt X} to unify with anything. +For instance, %% \begin{quote} \begin{verbatim} -?- insert{p(${a}),p(${#b})}. //Yes -?- p(${!X}). //Yes with X = ${a} -?- p(${#X@M}). //Yes with X = ${#b} and M = main -?- p(X). //Yes with X = ${a} or ${#b} +?- insert{p(${a}),p(${#b})}. // Yes +?- p(${!X}). // Yes, X gets bound to ${a} +?- p(${#X@M}). // Yes, X gets bound to ${#b} and M to main +?- p(X). // Yes, X gets bound to ${a} or ${#b} \end{verbatim} \end{quote} %% @@ -5387,174 +5595,6 @@ alternative mechanism that achieves many of the goals a cut is used for. -\section{Negation} \label{sec:negation} - - -\FLORA supports two kinds of negation: the usual Prolog's \emph{negation as - failure} \cite{Cla78} and negation based on \emph{well-founded semantics} -\cite{gelder-alternating-89,gelder-ross-schlipf-91}. Both types of negation -are compiled into clauses that invoke the corresponding operators in -Prolog. - -\subsection{Two Operators for Negation}\label{sec-negation} -\index{\TNOT} -\index{\NAF} -%% -Negation as failure is specified using the operator \NAF. Negation based -on the well-founded semantics is specified using the operator \TNOT. The -well-founded negation, \TNOT, applies to predicates that are tabled (i.e., -predicates that do not have the {\tt \#} prefix) or to F-molecules that do -not contain procedural methods (i.e., methods that are prefixed with a {\tt - \#}). - -The semantics for negation as failure is simple. To find out whether {\tt - \NAF G} is true, the system first asks the query {\tt ?- G}. If the query -succeeds then {\tt \NAF G} is said to be satisfied. Unfortunately, this -semantics is problematic. It cannot be characterized model-theoretically -and in certain simple cases the procedure for testing whether {\tt \NAF G} -holds may send the system into an infinite loop. For instance, in the -presence of the rule {\tt \#p :- \NAF \#p}, the query {\tt ?- \#p} will not -terminate. Negation as failure is the recommended kind of negation for -non-tabled predicates. - -The well-founded negation, \TNOT, has a model-theoretic semantics and is -much more -satisfactory from the logical point of view. -Formally, this semantics uses three-valued models where formulas can be -true, false, or undefined. For instance, if our program has the rule -{\tt p :- \TNOT p} then the truth value of {\tt p} is \emph{undefined}. -Although the details of this -semantics are somewhat involved \cite{gelder-ross-schlipf-91}, it is -usually not necessary to know them, because this type of negation yields -the results that the user normally expects. The implementation of -the well-founded negation in XSB requires that it is applied to goals that -consist entirely of tabled predicates or molecules. -Although \FLORA allows \TNOT to be applied to non-tabled goals, -this may lead to unexpected results. For instance, -Section~\ref{sec-updates} discusses what might happen if the -negated formula is defined in terms of an update primitive. - -For more information on the implementation of the negation operators in XSB -we refer the reader to the XSB manual. - -Both \NAF and \TNOT can be used as operators inside and outside \FLORA -molecules. For instance, -%% -\begin{alltt} - flora2 ?- \TNOT #p(a). - flora2 ?- \NAF #p(a). - flora2 ?- \TNOT X[foo->bar, bar->>foo]. - flora2 ?- X[\TNOT foo->bar, bar->>foo, \NAF #p(Y)]. -\end{alltt} -%% -are all legal queries. Note that \NAF applies only to non-tabled -constructs, such as non-tabled \FLORA predicates and procedural methods. - -We should warn against one pitfall however. Sometimes it is necessary to -apply negation to several separate literals and write something like -%% -\begin{alltt} - flora2 ?- \NAF(#p(a),#q(X)). - flora2 ?- \TNOT(p(a),q(X)). - flora2 ?- \TNOT(X[foo->bar], X[bar->>foo]). -\end{alltt} -%% -This is incorrect however, since in this context \FLORA (and Prolog as -well) will interpret \TNOT and \NAF as predicates with two arguments, -which are likely to be undefined. The correct syntax is: -%% -\begin{alltt} - flora2 ?- \NAF((#p(a),#q(X))). - flora2 ?- \TNOT((#p(a),#q(X))). - flora2 ?- \TNOT((X[foo->bar], X[bar->>foo])). -\end{alltt} -%% -{\it i.e.}, an additional pair of parentheses is needed to indicate that -the sequence of literals form a single argument. - -\subsection{True vs. Undefined Literals} - -The fact that the well-founded semantics for negation is three-valued -brings up the question of what exactly does the success or failure of a -call means. Is undefinedness covered by a success or by failure? The way -this is implemented in XSB is such that a call to a literal, $P$, succeeds -if and only if $P$ is true \emph{or} undefined. Therefore, it is sometimes -necessary to be able to separate true and undefined facts. In \FLORA, this -separation is accomplished by a call to the {\tt get\_residual/2} -predicate, which is provided by XSB. A call to -%% -\index{get\_residual/2} -%% -\begin{verbatim} - get_residual(Call,List)@prolog(tables) -\end{verbatim} -%% -succeeds if and only if {\tt Call} is either true or undefined according to -the well-founded semantics. Moreover, {\tt Call} is true iff {\tt List} is -nil ({\it i.e.}, {\tt []}). Thus, {\tt get\_residual(Call,[])@prolog(tables)} -succeeds if and only if {\tt Call} is true. - -\subsection{Unbound Variables in Negated Goals} - -When negation (either \NAF or \TNOT) is applied to a non-ground goal, one -should be aware of the following peculiarity. Consider {\tt \NAF Goal}, -where Goal has variables that are not bound. As mentioned before, -{\tt \NAF GOAL} is evaluated by posing {\tt Goal} as a query. If for -\emph{some} values of for the variables in {\tt Goal} the query succeeds, -then {\tt \NAF Goal} is false; it is true only if for \emph{all} possible -substitutions for the variables in {\tt Goal} the query is false -(fails). Therefore {\tt \NAF Goal} intuitively means $\tt\forall -Vars\,\neg\,Goal$, where {\tt Vars} represents all the nonbound variables -in {\tt Goal}. The well-founded negation has the same flavor: if {\tt - Goal} is non-ground then {\tt \TNOT GOAL} means $\tt\forall -Vars\,\neg\,Goal$. - -Of course, one should keep in mind that since neither {\tt \NAF} nor {\tt - \TNOT} is a classical negation, none of the above formulas is actually -equivalent to $\tt\forall Vars\,\neg\,Goal$, if $\neg$ is understood as -classical negation. A more precise meaning is that {\tt \TNOT Goal} is true -if and only if for every ground instance {\tt Goal$'$} of -{\tt Goal}, the literal {\tt \TNOT Goal$'$} is true in -the well-founded semantics. -Similarly, {\tt \NAF Goal} evaluates to true if and -only if for every ground instance {\tt Goal$'$} of {\tt Goal}, the query -{\tt \NAF Goal$'$} succeeds according to the negation-as-failure -semantics. - -To illustrate this, consider the following example: -%% -\begin{verbatim} - p(a,b). - q(X,Y) :- not p(X,Y). - flora ?- q(X,Y). -\end{verbatim} -%% -When {\tt not p(X,Y)} is called in the query evaluation process, the variables -are unbound, so for the query to return a positive answer, the literal {\tt - p(t,s)} should be false for every possible terms {\tt t} and {\tt s}. -Since {\tt p(a,b)} is true, our query {\tt q(X,Y)} fails. In contrast, the -query -%% -\begin{verbatim} - flora2 ?- q(b,Y). -\end{verbatim} -%% -will succeed because this will cause the query {\tt not p(b,Y)} to be -evaluated. But this query will return positive answer because {\tt p(b,Y)} -is false for all {\tt Y}. Note that even when the query succeeds the -unbound variable that occurs in the scope of the negation operator remains -unbound: -%% -\begin{verbatim} - flora2 ?- not p(b,Y). - - Y = _h1747 - - 1 solution(s) in 0.0000 seconds on speedy.foo.org -\end{verbatim} -%% - - \section{Updating the Knowledge Base}\label{sec-updates} |
|
From: Michael K. <ki...@us...> - 2005-03-24 06:48:27
|
Update of /cvsroot/flora/flora2/pkgs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5082/pkgs Modified Files: flrxml_aux.flr Log Message: cleanup Index: flrxml_aux.flr =================================================================== RCS file: /cvsroot/flora/flora2/pkgs/flrxml_aux.flr,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- flrxml_aux.flr 14 Mar 2005 03:04:41 -0000 1.6 +++ flrxml_aux.flr 24 Mar 2005 06:48:19 -0000 1.7 @@ -95,24 +95,24 @@ load_structure(X, Y, Z, W)@prologall(sgml), xml_parse_doc(Y, M)@prologall(flrxml), insertrule_z{ - (O1['$tag' -> Tag] :- _[Tag->>{O1}])@M, - (O2['$parent' -> O21] :- O21[_->>{O2}])@M, - (O3['$tag'(N) -> Tag] :- O3['$child'(N) -> _['$tag' -> Tag ]])@M}, + (O1['$tag' -> Tag] :- _[Tag->>{O1}], M=M)@M, + (O2['$parent' -> O21] :- O21[_->>{O2}], M=M)@M, + (O3['$tag'(N) -> Tag] :- O3['$child'(N)->_['$tag' -> Tag ]], M=M)@M + }, insertrule_z{ (O4['$childrenList' -> ChildrenList]:- - ( O4[_->>_]@M, - ChildrenList = collectset{Child | O4['$child'(_)->Child]@M} - ))@M}, + O4[_->>_], + ChildrenList = collectset{Child|O4['$child'(_)->Child]@M} )@M + }, insertrule_z{ (O5['$tagList' -> TagList ] :- - ( O5[_->>_]@M, - TagList = collectset{Tags | - O5['$child'(_)->_['$tag'-> Tags]]@M} - ))@M}, + O5[_->>_], + TagList = + collectset{Tags|O5['$child'(_)->_['$tag'-> Tags]]@M} )@M + }, insertrule_z{ (O6['$childrenNum' -> Counter ]:- - O6[_->>_]@M, - Counter = count{Children | O6['$child'(_)->Children]@M} - )@M + O6[_->>_], + Counter = count{Children|O6['$child'(_)->Children]@M} )@M }, !. |
|
From: Michael K. <ki...@us...> - 2005-03-24 06:48:03
|
Update of /cvsroot/flora/flora2/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4760/lib Modified Files: flrstorage.flr Log Message: fix the bug where tabled predicates weren't refreshed on backtracking Index: flrstorage.flr =================================================================== RCS file: /cvsroot/flora/flora2/lib/flrstorage.flr,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- flrstorage.flr 1 Aug 2004 18:47:22 -0000 1.5 +++ flrstorage.flr 24 Mar 2005 06:47:55 -0000 1.6 @@ -35,9 +35,9 @@ // This commit is only for user modules #commit(Module) :- flora_user_storage_name(Module,StorageName)@prolog(flrwrapper), - storage_commit(StorageName)@prolog(storage), - storage_reclaim_space(StorageName)@prolog(storage). + flora_db_commit(StorageName)@prolog(flrstoragebase), + flora_db_reclaim_space(StorageName)@prolog(flrstoragebase). #purgedb(Module) :- flora_user_storage_name(Module,StorageName)@prolog(flrwrapper), - storage_delete_all(StorageName)@prolog(storage). + flora_db_delete_all(StorageName)@prolog(flrstoragebase). |
|
From: Michael K. <ki...@us...> - 2005-03-24 06:48:03
|
Update of /cvsroot/flora/flora2/syslib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4760/syslib Modified Files: flrstoragebase.P flrbtdbop.P Log Message: fix the bug where tabled predicates weren't refreshed on backtracking Index: flrbtdbop.P =================================================================== RCS file: /cvsroot/flora/flora2/syslib/flrbtdbop.P,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- flrbtdbop.P 21 Mar 2005 06:54:59 -0000 1.24 +++ flrbtdbop.P 24 Mar 2005 06:47:55 -0000 1.25 @@ -827,8 +827,12 @@ *****************************************************************************/ flora_internal_db_insert_bt(StorageName,Call) :- flora_db_insert_base_bt(StorageName,Call), + %% On backtracking, refresh is done in flora_storage_insert_fact_bt + %% in flrstoragebase.P flora_refresh_tables(Call). flora_internal_db_delete_bt(StorageName,Call) :- flora_db_delete_base_bt(StorageName,Call), + %% On backtracking, refresh is done in flora_storage_delete_fact_bt + %% in flrstoragebase.P flora_refresh_tables(Call). Index: flrstoragebase.P =================================================================== RCS file: /cvsroot/flora/flora2/syslib/flrstoragebase.P,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- flrstoragebase.P 26 Sep 2004 17:17:10 -0000 1.6 +++ flrstoragebase.P 24 Mar 2005 06:47:55 -0000 1.7 @@ -37,23 +37,19 @@ flora_db_insert_base_bt/2, flora_db_delete_base_bt/2, flora_db_find_base/2, + flora_db_delete_all/1, flora_db_commit/1, flora_db_reclaim_space/1. -#define FLORA_USE_TRIES +:- import trie_intern/5, trie_interned/4, trie_unintern_nr/2, + unmark_uninterned_nr/2, + delete_trie/1, + trie_reclaim_uninterned_nr/1 + from intern. -#ifdef FLORA_USE_TRIES +:- import flora_refresh_tables/1 from flrtables. -:- import - storage_find_fact/2, - storage_insert_fact/3, - storage_delete_fact/3, - storage_insert_fact_bt/3, - storage_delete_fact_bt/3, - storage_commit/1, - storage_reclaim_space/1 - from storage. :- import flora_trim_last/2 from flrtrim. @@ -67,17 +63,19 @@ from flrdbmodule. %% Lop off the last argument before inserting/querying the database +%% exported flora_db_insert_base(StorageName,Call) :- flora_trim_last(Call, CallSansCaller), - storage_insert_fact(StorageName,CallSansCaller,_ResultFlag), + flora_storage_insert_fact(StorageName,CallSansCaller,_ResultFlag), %%insert to the database associated with the module (if any). fllibdbmodule_insert(Call). +%% exported flora_db_delete_base(StorageName,Call) :- flora_trim_last(Call, CallSansCaller), %%may or may not be present in main memory. ( - storage_delete_fact(StorageName,CallSansCaller,_ResultFlag), + flora_storage_delete_fact(StorageName,CallSansCaller,_ResultFlag), ( %%even if this fails, return success as deletion from %%main memory is successful. @@ -89,16 +87,19 @@ fllibdbmodule_delete(Call) ). +%% exported flora_db_insert_base_bt(StorageName,Call) :- flora_trim_last(Call, CallSansCaller), - storage_insert_fact_bt(StorageName,CallSansCaller,_ResultFlag). + flora_storage_insert_fact_bt(StorageName,CallSansCaller,Call,_ResultFlag). +%% exported flora_db_delete_base_bt(StorageName,Call) :- flora_trim_last(Call, CallSansCaller), - storage_delete_fact_bt(StorageName,CallSansCaller,_ResultFlag). + flora_storage_delete_fact_bt(StorageName,CallSansCaller,Call,_ResultFlag). %% Used to search database of facts +%% exported flora_db_find_base(StorageName,Call) :- flora_trim_last(Call, CallSansCaller), ( @@ -113,18 +114,12 @@ ) ) ; - storage_find_fact(StorageName,CallSansCaller) + flora_storage_find_fact(StorageName,CallSansCaller) ). -%% Commit and reclaim -flora_db_commit(StorageName) :- - storage_commit(StorageName). - -flora_db_reclaim_space(StorageName) :- - storage_reclaim_space(StorageName). -#else +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Here we need to implement backtrackable updates using assert and retract_nr #include "storage_xsb_defs.h" @@ -136,7 +131,7 @@ %% Inserts facts. On backtracking, the fact is deleted. -storage_insert_fact_bt(StorageName,Fact,Inserted) :- +flora_storage_insert_fact_bt(StorageName,Fact,Call,Inserted) :- triehandle_for_storage(StorageName,H,Snapshot), trie_intern(Fact, H, Leaf, New, _), (New == 0 @@ -146,7 +141,14 @@ ; %% On backtracking triehandle_for_storage(StorageName,_,NewSnapshot), (NewSnapshot =< Snapshot - -> trie_unintern_nr(H, Leaf), fail + -> trie_unintern_nr(H, Leaf), + %% Here we only refresh on backtracking. Normal + %% refresh is done in flrbtdbop.P and flrdbop.P + %% Can't be done here (esp. in flora_storage_insert_fact: + %% this predicate is too low level and is used elsewhere. + %% Refreshig of tables at this low level can be dangerous + flora_refresh_tables(Call), + fail ) ) ; Inserted=0 % fact was already there: no action @@ -154,7 +156,7 @@ %% Nonbacktrackable insert -storage_insert_fact(StorageName,Fact,Inserted) :- +flora_storage_insert_fact(StorageName,Fact,Inserted) :- triehandle_for_storage(StorageName,H,_), trie_intern(Fact, H, _Leaf, New, _), (New == 0 @@ -167,7 +169,7 @@ %% Doesn't remove anything, but instead "marks" for deletion. %% On backtracking: unmarks facts that are marked for deletion -storage_delete_fact_bt(StorageName,Fact,Deleted) :- +flora_storage_delete_fact_bt(StorageName,Fact,Call,Deleted) :- triehandle_for_storage(StorageName,H,Snapshot), (trie_interned(Fact, H, Leaf, _) -> Deleted=1, % existing fact deleted @@ -176,14 +178,21 @@ ; %% On backtracking triehandle_for_storage(StorageName,_,NewSnapshot), (NewSnapshot =< Snapshot - -> unmark_uninterned_nr(H, Leaf), fail + -> unmark_uninterned_nr(H, Leaf), + %% Here we only refresh on backtracking. Normal + %% refresh is done in flrbtdbop.P and flrdbop.P + %% Can't be done here (esp. in flora_storage_delete_fact: + %% this predicate is too low level and is used elsewhere. + %% Refreshig of tables at this low level can be dangerous + flora_refresh_tables(Call), + fail ) ) ; Deleted=0 % non-existing fact: no action ). %% Nonbacktrackable delete -storage_delete_fact(StorageName,Fact,Deleted) :- +flora_storage_delete_fact(StorageName,Fact,Deleted) :- triehandle_for_storage(StorageName,H,_), (trie_interned(Fact, H, Leaf, _) -> Deleted=1, % existing fact deleted @@ -192,14 +201,15 @@ ). %% deletes the whole trie -storage_delete_all(StorageName) :- +%% exported +flora_db_delete_all(StorageName) :- triehandle_for_storage(StorageName,H,_), storage_builtin(DESTROY_STORAGE_HANDLE,StorageName,_,_,_), delete_trie(H). %% Find fact in storage -storage_find_fact(StorageName,Fact) :- +flora_storage_find_fact(StorageName,Fact) :- triehandle_for_storage(StorageName,H,_), trie_interned(Fact, H, _, _). @@ -207,7 +217,8 @@ %% Commit changes to the storage trie associated with StorageName %% (only if storage has been changed) -storage_commit(StorageName) :- +%% exported +flora_db_commit(StorageName) :- ( storage_builtin(INCREMENT_STORAGE_SNAPSHOT,StorageName,_,_,_), ! %% don't backtrack over it @@ -217,7 +228,8 @@ %% Reclaims space by removing nodes from the backtrackable insert/keypair trie %% which were marked for deletion. This should be done only at the top %% level of a query. -storage_reclaim_space(StorageName) :- +%% exported +flora_db_reclaim_space(StorageName) :- triehandle_for_storage(StorageName,H,_), trie_reclaim_uninterned_nr(H). @@ -231,6 +243,3 @@ %% This one seems no longer used. Check!!! mark_storage_changed_bt(StorageName) :- storage_builtin(MARK_STORAGE_CHANGED,StorageName,_,_,_). - - -#endif |
|
From: Michael K. <ki...@us...> - 2005-03-24 06:48:03
|
Update of /cvsroot/flora/flora2/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4760/includes Modified Files: flrdefinition.flh Log Message: fix the bug where tabled predicates weren't refreshed on backtracking Index: flrdefinition.flh =================================================================== RCS file: /cvsroot/flora/flora2/includes/flrdefinition.flh,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- flrdefinition.flh 26 Sep 2004 03:58:45 -0000 1.14 +++ flrdefinition.flh 24 Mar 2005 06:47:55 -0000 1.15 @@ -10,11 +10,8 @@ #include "flora_errors.flh" :- import - storage_delete_all/1, - storage_find_fact/2, - storage_insert_fact/3, - storage_delete_fact/3 - from storage. + flora_db_delete_all/1 + from flrstoragebase. :- import flora_load_dyndata_for_user_modules/1, FLORA_SYMBOL('debugger_loaded')/0 @@ -39,12 +36,12 @@ :- import flora_reset_export_registries/1 from flrexport. :- import flora_reset_rule_signature/1 from flrcanon. -?- storage_delete_all(FLORA_THIS_FLD_STORAGE). +?- flora_db_delete_all(FLORA_THIS_FLD_STORAGE). ?- flora_in_debug_mode(_), !, assert(flora_debug_module_registry(FLORA_THIS_MODULE_NAME)) ; true. -?- storage_delete_all(FLORA_THIS_FDB_STORAGE). +?- flora_db_delete_all(FLORA_THIS_FDB_STORAGE). ?- (flora_storage_registry(FLORA_THIS_FDB_STORAGE), ! ; assert(flora_storage_registry(FLORA_THIS_FDB_STORAGE)) ). |
|
From: Michael K. <ki...@us...> - 2005-03-22 21:11:12
|
Update of /cvsroot/flora/flora-website In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18796 Modified Files: relatedWorks.php aboutTR.php Log Message: Index: relatedWorks.php =================================================================== RCS file: /cvsroot/flora/flora-website/relatedWorks.php,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- relatedWorks.php 13 Mar 2005 00:16:01 -0000 1.7 +++ relatedWorks.php 22 Mar 2005 21:10:39 -0000 1.8 @@ -58,7 +58,7 @@ Web Services Modeling Ontology</a> project. </li> <li> - <a href="ftp://ftp.cs.sunysb.edu/pub/TechReports/kifer/ctrs-www2004.pdf"> + <a href="CTR-S: A Logic for Specifying Contracts in Semantic Web Services"> CTR-S: A Logic for Specifying Contracts in Semantic Web Services </a> Proceddings of the 13-th World Wide Web Conference (WWW2004), May 2004. @@ -79,7 +79,7 @@ Proceedings of PODS 1999. </li> <li> - <a href="ftp://ftp.cs.sunysb.edu/pub/TechReports/kifer/cctr02.pdf"> + <a href="http://citeseer.ist.psu.edu/senkul02logical.html"> A Logical Framework for Scheduling Workflows Under Resource Allocation Constraints. </a> Index: aboutTR.php =================================================================== RCS file: /cvsroot/flora/flora-website/aboutTR.php,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- aboutTR.php 13 Mar 2005 00:16:01 -0000 1.7 +++ aboutTR.php 22 Mar 2005 21:10:40 -0000 1.8 @@ -41,7 +41,7 @@ </li> <li> <a - href="ftp://ftp.cs.sunysb.edu/pub/TechReports/kifer/tr-reasoning.pdf">Results + href="http://citeseer.ist.psu.edu/bonner98results.html">Results on Reasoning about Updates in Transaction Logic</a> in Transactions and Change in Logic Databases, Lecture Notes in Computer Science, vol. 1472, @@ -62,6 +62,36 @@ modeling and verification of workflows</a> (Intl. ACM Conference on Principles of Database Systems, 1998). </li> +<li> + <a href="http://www.www2004.org/proceedings/docs/2p144.pdf"> + CTR-S: A Logic for Specifying Contracts in Semantic Web Services + </a> + Proceddings of the 13-th World Wide Web Conference (WWW2004), May 2004. +</li> +<li> + Older papers: +</li> +<ul> + <li> + <a href="http://citeseer.ist.psu.edu/bonner93transaction.html"> + Transaction Logic Programming, + </a> + International Conference on Logic Programming, 1993. + </li> +<li> + <a href="http://citeseer.ist.psu.edu/bonner94overview.html"> + An Overview of Transaction Logic, + </a> + Theoretical Computer Science, 133:2, 1994. +</li> +<li> + <a + href="ftp://ftp.cs.sunysb.edu/pub/TechReports/kifer/tr-db-programming.pdf"> + Database Programming in Transaction Logic</a>. Proceedings of the Fourth + International Workshop on Database Programming Languages - Object Models + and Languages, 1993. +</li> +</ul> </ul> |
|
From: Chang Z. <ch...@us...> - 2005-03-22 06:21:05
|
Update of /cvsroot/flora/flora2/syslib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25842/syslib Modified Files: flrdecode.P flrmetaops.P Log Message: use !-prefixed variable instead of just variable for tabled methods; meta-unific ation no longer unifies arguments but meta-unifies them. Index: flrmetaops.P =================================================================== RCS file: /cvsroot/flora/flora2/syslib/flrmetaops.P,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- flrmetaops.P 21 Mar 2005 06:55:00 -0000 1.13 +++ flrmetaops.P 22 Mar 2005 06:20:57 -0000 1.14 @@ -101,6 +101,19 @@ !, X=Y. +%% speed up the case where X unifies with Y +FLLIBUNIVEQFORM(X,Y) :- + atomic(X), + atomic(Y), + !, + X=Y. + +FLLIBUNIVEQFORM(X,Y) :- + X \= FLLIBMODLIT(_,_,_,_), X \= ','(FLLIBMODLIT(_,_,_,_),_), + Y \= FLLIBMODLIT(_,_,_,_), Y \= ','(FLLIBMODLIT(_,_,_,_),_), + X=Y, + !. + FLLIBUNIVEQFORM(FL_HASHED(X),FL_HASHED(Y)) :- var(X), !, @@ -336,7 +349,8 @@ WrapY \== FL_LIBMOD, !, WrapX = WrapY, - X=Y, + univeqform_list(X,Y), + %%%%X=Y, MX=MY. FLLIBUNIVEQFORM(FLSYSRULEUPDATE(H1,B1),FLSYSRULEUPDATE(H2,B2)) :- @@ -381,17 +395,21 @@ GX = X, GY = Y ), - GX=GY. + GX =.. XList, + GY =.. YList, + univeqform_list(XList,YList). + %%%%GX=GY. %% Common (expensive) case FLLIBUNIVEQFORM(X,Y) :- get_canonical_form(X,FLCANON(Wrap1,Args,Mod1,Callable1,TableFlag)), - get_canonical_form(Y,FLCANON(Wrap2,Args,Mod2,Callable2,TableFlag)), + get_canonical_form(Y,FLCANON(Wrap2,Args2,Mod2,Callable2,TableFlag)), ( Mod1==FL_INVALIDMODULE -> ( Mod2==FL_INVALIDMODULE -> true; Mod=Mod2) ; ( Mod2==FL_INVALIDMODULE -> Mod=Mod1; Mod=Mod1,Mod=Mod2) ), + (nonvar(Args),nonvar(Args2) -> univeqform_list(Args,Args2); Args=Args2), (nonvar(Args) -> Wrap1=Wrap2; true), ( var(Callable1),nonvar(Wrap1),nonvar(Args),nonvar(Mod) -> flora_module_predicate(Wrap1,Args,Mod,Callable1); true), @@ -409,6 +427,11 @@ ). +univeqform_list([],[]) :- !. +univeqform_list([H1|L1], [H2|L2]) :- + FLLIBUNIVEQFORM(H1,H2), + univeqform_list(L1,L2). + /****************************************************************************** FLLIBMETAUNIV(?X,?Y) The meta predicate =.. Index: flrdecode.P =================================================================== RCS file: /cvsroot/flora/flora2/syslib/flrdecode.P,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- flrdecode.P 21 Mar 2005 06:55:00 -0000 1.32 +++ flrdecode.P 22 Mar 2005 06:20:57 -0000 1.33 @@ -39,7 +39,8 @@ from basics. :- import - flora_decode_predicate/6 + flora_decode_predicate/6, + is_flora_callable_literal/1 from flrwrapper. :- import flora_prlgdef/2 from flrprolog. :- import flora_opdef/3 from flroperator. @@ -710,14 +711,19 @@ Level,Depth) :- !, %% Don't increment nesting level - (Level==0 -> ReifyStart='',ReifyEnd='' ; ReifyStart='${',ReifyEnd='}'), ((var(Args) ; atomic(Args)) - -> ArgCode = Args + -> ArgCode = Args, workspace_code(Module,ModuleCode), + (Level==0 -> ReifyStart='',ReifyEnd='' ; ReifyStart='${',ReifyEnd='}') + ; (Args = FLLIBMODLIT(_,_,_,_); is_flora_callable_literal(Args)) -> + ReifyStart='',ReifyEnd='',ModuleCode='', + Depth1 is Depth+1, + decode_literal_internal(Args,ArgCode,Level,Depth1) ; + (Level==0 -> ReifyStart='',ReifyEnd='' ; ReifyStart='${',ReifyEnd='}'), Depth1 is Depth+1, - decode_literal_internal(Args,ArgCode,Level,Depth1) - ), - workspace_code(Module,ModuleCode). + decode_literal_internal(Args,ArgCode,Level,Depth1), + workspace_code(Module,ModuleCode) + ). %% This occurs when you have flogic-lit@Module, where Module is a var decode_literal_internal(FLLIBMODLIT(Basename,Args,Module,_Caller),Code,Level,Depth) :- |
|
From: Chang Z. <ch...@us...> - 2005-03-22 06:21:05
|
Update of /cvsroot/flora/flora2/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25842/lib Modified Files: flrprettyprint.flr Log Message: use !-prefixed variable instead of just variable for tabled methods; meta-unific ation no longer unifies arguments but meta-unifies them. Index: flrprettyprint.flr =================================================================== RCS file: /cvsroot/flora/flora2/lib/flrprettyprint.flr,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- flrprettyprint.flr 14 Sep 2004 06:12:45 -0000 1.10 +++ flrprettyprint.flr 22 Mar 2005 06:20:57 -0000 1.11 @@ -86,11 +86,11 @@ #flora_pp_write_body_iscalar(X,Module), #flora_pp_write_comma_conditional(${X[(_->_; _->>_;_*->_),_*->>_]@Module}), #flora_pp_write_body_iset(X,Module), - #flora_pp_write_comma_conditional(${X[(_->_; _->>_;_*->_;_*->>_),_]@Module}), + #flora_pp_write_comma_conditional(${X[(_->_; _->>_;_*->_;_*->>_),!_]@Module}), #flora_pp_write_body_bool(X,Module), - #flora_pp_write_comma_conditional(${X[(_->_; _->>_;_*->_;_*->>_,_),*_]@Module}), + #flora_pp_write_comma_conditional(${X[(_->_; _->>_;_*->_;_*->>_,!_),*_]@Module}), #flora_pp_write_body_ibool(X,Module), - #flora_pp_write_comma_conditional(${X[(_->_; _->>_;_*->_;_*->>_,_,*_),#_]@Module}), + #flora_pp_write_comma_conditional(${X[(_->_; _->>_;_*->_;_*->>_,!_,*_),#_]@Module}), #flora_pp_write_body_tran(X,Module), nl@prolog(), writeln('].')@prolog(), nl@prolog(). // Print obj in Module to an Outfile @@ -227,7 +227,7 @@ // Boolean p(...) #flora_pp_write_body_bool(Obj,Module) :- - MethLst1 = collectset{Bool | Obj[Bool]@Module}, + MethLst1 = collectset{Bool | Obj[!Bool]@Module}, sort(MethLst1, MethLst2)@prolog(), #flora_pp_write_body_bool1(Obj, MethLst2,Module). |
|
From: Chang Z. <ch...@us...> - 2005-03-22 06:21:05
|
Update of /cvsroot/flora/flora2/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25842/docs Modified Files: flora2.tex Log Message: use !-prefixed variable instead of just variable for tabled methods; meta-unific ation no longer unifies arguments but meta-unifies them. Index: flora2.tex =================================================================== RCS file: /cvsroot/flora/flora2/docs/flora2.tex,v retrieving revision 1.125 retrieving revision 1.126 diff -u -d -r1.125 -r1.126 --- flora2.tex 21 Mar 2005 22:38:33 -0000 1.125 +++ flora2.tex 22 Mar 2005 06:20:56 -0000 1.126 @@ -3369,7 +3369,6 @@ %% - \index{HiLog!unification} % Like in classical logic, {\tt foo} and {\tt foo()} are different terms. @@ -3546,38 +3545,38 @@ {\tt (a[b->c]@foo)@N)} at run time and, due to the scoping rules, is the same as {\tt a[b->c]@foo}. -One more thing to know about meta-unification is that it is done at -the predicate level; the arguments of the predicates involved in a -meta-unification operation are not meta-unified. -Thus the following query will fail because although {\tt p@M} and -{\tt p@foo} meta-unify, they do not unify in the regular sense. -%% -\begin{quote} -\begin{verbatim} -?- X ~ p@M, Y ~ p@foo, pp(X) ~ pp(Y). -\end{verbatim} -\end{quote} -%% -If the user wants meta-unification for the argument in the above -example, she can reify the arguments (see the next section). For instance, -the following query succeeds. -%% -\begin{quote} -\begin{verbatim} -?- X ~ p@M, Y ~ p@foo, pp(${X@_M1}) ~ pp(${Y@_M2}). -\end{verbatim} -\end{quote} -%% -Notice that the following query still fails because reification does not -have any effect if the reified formula is a variable and therefore the -query is the same as the one without reification. -%% -\begin{quote} -\begin{verbatim} -?- X ~ p@M, Y ~ p@foo, pp(${X}) ~ pp(${Y}). -\end{verbatim} -\end{quote} -%% +%% One more thing to know about meta-unification is that it is done at +%% the predicate level; the arguments of the predicates involved in a +%% meta-unification operation are not meta-unified. +%% Thus the following query will fail because although {\tt p@M} and +%% {\tt p@foo} meta-unify, they do not unify in the regular sense. +%% %% +%% \begin{quote} +%% \begin{verbatim} +%% ?- X ~ p@M, Y ~ p@foo, pp(X) ~ pp(Y). +%% \end{verbatim} +%% \end{quote} +%% %% +%% If the user wants meta-unification for the argument in the above +%% example, she can reify the arguments (see the next section). For instance, +%% the following query succeeds. +%% %% +%% \begin{quote} +%% \begin{verbatim} +%% ?- X ~ p@M, Y ~ p@foo, pp(${X@_M1}) ~ pp(${Y@_M2}). +%% \end{verbatim} +%% \end{quote} +%% %% +%% Notice that the following query still fails because reification does not +%% have any effect if the reified formula is a variable and therefore the +%% query is the same as the one without reification. +%% %% +%% \begin{quote} +%% \begin{verbatim} +%% ?- X ~ p@M, Y ~ p@foo, pp(${X}) ~ pp(${Y}). +%% \end{verbatim} +%% \end{quote} +%% %% \subsection{Reification} @@ -4940,9 +4939,8 @@ %% Identifiers and variables that are prefixed with the ``\verb|#|'' sign -can appear only as predicate formulas, predicate names, or procedural -Boolean method names. Variables prefixed with ``\verb|!|'' can appear -only as predicate formulas or predicates names. The following +and variables prefixed with ``\verb|!|'' can appear only as predicate +formulas, predicate names, or Boolean method names. The following occurrences of ``\verb|#|'' and ``\verb|!|'' are legal %% \begin{quote} @@ -4951,6 +4949,7 @@ ?- a[#b(c)], a[#Y]. // #b and #Y are procedural Boolean methods ?- #X ~ #p(a). // #X is a variable, #p is a non-tabled predicate ?- !X ~ p(a). // !X is a variable +?- a[!Y]. // !Y is a Boolean method \end{verbatim} \end{quote} %% @@ -4963,7 +4962,6 @@ ?- #X = a. // #X appears as a term, not formula ?- !X = a. // !X appears as a term, not formula ?- a[#b(c)->d]. // #b is not a Boolean method -?- a[!Y]. // !Y is not allowed as method \end{verbatim} \end{quote} %% |
|
From: Chang Z. <ch...@us...> - 2005-03-22 06:21:04
|
Update of /cvsroot/flora/flora2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25842 Modified Files: flrparser.P Log Message: use !-prefixed variable instead of just variable for tabled methods; meta-unific ation no longer unifies arguments but meta-unifies them. Index: flrparser.P =================================================================== RCS file: /cvsroot/flora/flora2/flrparser.P,v retrieving revision 1.73 retrieving revision 1.74 diff -u -d -r1.73 -r1.74 --- flrparser.P 21 Mar 2005 06:55:01 -0000 1.73 +++ flrparser.P 22 Mar 2005 06:20:54 -0000 1.74 @@ -49,7 +49,6 @@ #define DISALLOW_VARIABLES disallow_variables #define DISALLOW_HASH disallow_hash %% neither # nor ! is allowed -#define ALLOW_HASH_NOPREFIX allow_hash_noprefix %% for method #define ALLOW_HASH_EXCL allow_hash_excl %% predicate name %% If the module specification is for a dynamic rule (eg. foo in @@ -3200,7 +3199,17 @@ ). flora_attmeth_template(CanoniTerm,Code,Status) :- - flora_term_template(CanoniTerm,ALLOW_HASH_NOPREFIX,C,Status), + flexclobject_struct(CanoniTerm,C), + !, + (is_flexclvar_struct(C), not is_anonymous_flexclvar_struct(C) -> + parsing_error(CanoniTerm,ERROR_NAMEDVAR,Status) + ; + flmethspec_struct(C,Code), + Status = [] + ). + +flora_attmeth_template(CanoniTerm,Code,Status) :- + flora_term_template(CanoniTerm,ALLOW_HASH_EXCL,C,Status), (Status == [] -> ((is_flhashedterm_struct(C);is_flhashedobject_struct(C)) -> fltranspec_struct(C,Code) @@ -3268,8 +3277,7 @@ ; Status = [] ). -flora_term_template(ObjectTerm,HashFlag,Code,Status) :- - (HashFlag==ALLOW_HASH_NOPREFIX;HashFlag==ALLOW_HASH_EXCL), +flora_term_template(ObjectTerm,ALLOW_HASH_EXCL,Code,Status) :- flhashedobject_struct(ObjectTerm,Code), !, (is_flhashedvar_struct(Code), not is_anonymous_flhashedvar_struct(Code) -> @@ -3464,7 +3472,7 @@ flora_term(Funct,N,Args,HashFlag,Code,Status) :- flhashedobject_struct(Funct,F), !, - ( (HashFlag==ALLOW_HASH_NOPREFIX;HashFlag==ALLOW_HASH_EXCL) -> + ( HashFlag==ALLOW_HASH_EXCL -> flora_pathexplist(Args,AList,Status), (Status == [] -> flhashedterm_struct(F,N,AList,Code); true) ; @@ -3928,8 +3936,13 @@ !, fltranspec_struct(C,Code). +flora_attmethspec(CanoniTerm,Code,[]) :- + flexclobject_struct(CanoniTerm,C), + !, + flmethspec_struct(C,Code). + flora_attmethspec(CanoniTerm,Code,Status) :- - flora_pathexp(CanoniTerm,ALLOW_HASH_NOPREFIX,C,Status), + flora_pathexp(CanoniTerm,ALLOW_HASH_EXCL,C,Status), (Status == [] -> (is_flhashedterm_struct(C) -> fltranspec_struct(C,Code) @@ -4068,7 +4081,7 @@ flora_head_term(Funct,N,Args,HashFlag,Code,Status) :- flhashedobject_struct(Funct,F), !, - ( (HashFlag==ALLOW_HASH_NOPREFIX;HashFlag==ALLOW_HASH_EXCL) -> + ( HashFlag==ALLOW_HASH_EXCL -> flora_head_pathexplist(Args,AList,Status), (Status == [] -> flhashedterm_struct(F,N,AList,Code); true) ; @@ -4329,8 +4342,13 @@ !, fltranspec_struct(C,Code). +flora_head_attmethspec(CanoniTerm,Code,[]) :- + flexclobject_struct(CanoniTerm,C), + !, + flmethspec_struct(C,Code). + flora_head_attmethspec(CanoniTerm,Code,Status) :- - flora_head_pathexp(CanoniTerm,ALLOW_HASH_NOPREFIX,C,Status), + flora_head_pathexp(CanoniTerm,ALLOW_HASH_EXCL,C,Status), (Status == [] -> (is_flhashedterm_struct(C) -> fltranspec_struct(C,Code) @@ -4852,7 +4870,7 @@ flora_db_term(Mode,Funct,N,Args,HF,Code,Status) :- flhashedobject_struct(Funct,F), !, - ( (HF==ALLOW_HASH_NOPREFIX;HF==ALLOW_HASH_EXCL) -> + ( HF==ALLOW_HASH_EXCL -> flora_db_pathexplist(Mode,Args,AList,Status), (Status == [] -> flhashedterm_struct(F,N,AList,Code); true) ; @@ -5148,8 +5166,13 @@ !, fltranspec_struct(C,Code). +flora_db_attmethspec(_Mode,CanoniTerm,Code,[]) :- + flexclobject_struct(CanoniTerm,C), + !, + flmethspec_struct(C,Code). + flora_db_attmethspec(Mode,CanoniTerm,Code,Status) :- - flora_db_pathexp(Mode,CanoniTerm,ALLOW_HASH_NOPREFIX,C,Status), + flora_db_pathexp(Mode,CanoniTerm,ALLOW_HASH_EXCL,C,Status), (Status == [] -> (is_flhashedterm_struct(C) -> fltranspec_struct(C,Code) |
|
From: Chang Z. <ch...@us...> - 2005-03-22 06:20:02
|
Update of /cvsroot/flora/flora-testsuite/general_tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24078/general_tests Modified Files: hashtest.flr hashtest_old intermod_neg.flr metaupdates.flr moduletst.flr Log Message: use !-prefixed variable instead of just variable for tabled methods; meta-unification no longer unifies arguments but meta-unifies them. Index: hashtest.flr =================================================================== RCS file: /cvsroot/flora/flora-testsuite/general_tests/hashtest.flr,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- hashtest.flr 21 Mar 2005 22:36:00 -0000 1.3 +++ hashtest.flr 22 Mar 2005 06:19:45 -0000 1.4 @@ -52,8 +52,9 @@ flora_write_goal(ans(X,Y))@prolog(flrdecode), nl@prolog(). #tst17 :- unless (X ~ p(a), X ~ #p(a)) do writeln('tst17 failed as expected')@prolog(). -#tst18 :- unless (X ~ p@_M, Y ~ p@foo, pp(X) ~ pp(Y)) - do writeln('tst18 failed as expected')@prolog(). +#tst18 :- X ~ p@M, Y ~ p@foo, pp(X) ~ pp(Y), + write('tst18 succeeded, as expected = ')@prolog(), + flora_write_goal(ans(X,M,Y))@prolog(flrdecode), nl@prolog(). #tst19 :- X ~ p@M, Y ~ p@foo, pp(${!X}) ~ pp(${!Y}), write('tst19 succeeded, as expected = ')@prolog(), flora_write_goal(ans(X,M,Y))@prolog(flrdecode), nl@prolog(). Index: moduletst.flr =================================================================== RCS file: /cvsroot/flora/flora-testsuite/general_tests/moduletst.flr,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- moduletst.flr 27 Aug 2004 05:50:03 -0000 1.5 +++ moduletst.flr 22 Mar 2005 06:19:53 -0000 1.6 @@ -57,7 +57,7 @@ write('tst10: ')@prolog(), writeln(Mod)@prolog(), fail. #tst10 :- true. -#tst11 :- q[X]@Mod, +#tst11 :- q[!X]@Mod, write('tst11: ')@prolog(), writeln(X=Mod)@prolog(), fail. #tst11 :- true. Index: hashtest_old =================================================================== RCS file: /cvsroot/flora/flora-testsuite/general_tests/hashtest_old,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- hashtest_old 2 Feb 2005 12:04:39 -0000 1.1 +++ hashtest_old 22 Mar 2005 06:19:47 -0000 1.2 @@ -15,7 +15,7 @@ tst15 failed as expected tst16 succeeded, as expected = ans(${p(a)},${a[#b]}) tst17 failed as expected -tst18 failed as expected +tst18 succeeded, as expected = ans(${p@foo},foo,${p@foo}) tst19 succeeded, as expected = ans(${p@foo},foo,${p@foo}) tst20 succeeded, as expected = ans(${p},${#q@foo},foo,main,${#q@foo}) tst21 succeeded, as expected = ans(main,${p},${#q@foo},foo) @@ -36,7 +36,7 @@ tst15 failed as expected tst16 succeeded, as expected = ans(${p(a)},${a[#b]}) tst17 failed as expected -tst18 failed as expected +tst18 succeeded, as expected = ans(${p@foo},foo,${p@foo}) tst19 succeeded, as expected = ans(${p@foo},foo,${p@foo}) tst20 succeeded, as expected = ans(${p},${#q@foo},foo,main,${#q@foo}) tst21 succeeded, as expected = ans(main,${p},${#q@foo},foo) Index: metaupdates.flr =================================================================== RCS file: /cvsroot/flora/flora-testsuite/general_tests/metaupdates.flr,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- metaupdates.flr 21 Mar 2005 06:52:16 -0000 1.7 +++ metaupdates.flr 22 Mar 2005 06:19:53 -0000 1.8 @@ -27,27 +27,27 @@ insert{X}, flora_write_goal(X)@prolog(flrdecode), nl@prolog(). -#tst10 :- write('tst10: ')@prolog(), p[X], +#tst10 :- write('tst10: ')@prolog(), p[!X], write('x=')@prolog(), flora_write_goal(X)@prolog(flrdecode), - q[Y], + q[!Y], write(' y=')@prolog(), flora_write_goal(Y)@prolog(flrdecode), nl@prolog(). -#tst11 :- write('tst11: ')@prolog(), X= ${a@main}, q[Y], X = Y, +#tst11 :- write('tst11: ')@prolog(), X= ${a@main}, q[!Y], X = Y, flora_write_goal(X)@prolog(flrdecode), nl@prolog(). -#tst12 :- write('tst12: ')@prolog(), X= ${a@main}, p[Y], X = Y, +#tst12 :- write('tst12: ')@prolog(), X= ${a@main}, p[!Y], X = Y, flora_write_goal(X)@prolog(flrdecode), nl@prolog(). #tst13 :- write('tst13: ')@prolog(), Y= a(), Z=main, X = ${pp[${!Y@Z}]}, insert{X}, flora_write_goal(X)@prolog(flrdecode), nl@prolog(). -#tst14 :- write('tst14: ')@prolog(), pp[X], +#tst14 :- write('tst14: ')@prolog(), pp[!X], flora_write_goal(X)@prolog(flrdecode), nl@prolog(), X = ${a@main}. #tst15 :- write('tst15: ')@prolog(), Y= a(),Z=main,insert{qq[${!Y@Z}]}, writeln(' done')@prolog(). -#tst16 :- write('tst16: ')@prolog(), qq[X], +#tst16 :- write('tst16: ')@prolog(), qq[!X], flora_write_goal(X)@prolog(flrdecode), nl@prolog(), X = ${a@main}. #tst17 :- write('tst17: ')@prolog(), Index: intermod_neg.flr =================================================================== RCS file: /cvsroot/flora/flora-testsuite/general_tests/intermod_neg.flr,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- intermod_neg.flr 2 Feb 2005 12:07:44 -0000 1.6 +++ intermod_neg.flr 22 Mar 2005 06:19:47 -0000 1.7 @@ -3,7 +3,7 @@ // Some tests for intermodule negation ?- insert{p[a]}. -?- insertrule_z{(#p(X) :- not p[X])}. +?- insertrule_z{(#p(X) :- not p[!X])}. ?- newmodule{foo}. ?- insertrule_z{(#q(X) :- caller{Y}, #writeln(tst1_caller=Y)@flora(io),#p(X)@main)@foo}. |
|
From: Chang Z. <ch...@us...> - 2005-03-21 22:38:44
|
Update of /cvsroot/flora/flora2/syslib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23111/syslib Modified Files: flrcanon.P Log Message: introduce !-prefixed variables for tabled predicates Index: flrcanon.P =================================================================== RCS file: /cvsroot/flora/flora2/syslib/flrcanon.P,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- flrcanon.P 21 Mar 2005 06:54:59 -0000 1.21 +++ flrcanon.P 21 Mar 2005 22:38:34 -0000 1.22 @@ -617,7 +617,7 @@ var(Head), !, flora_rule_signature(Prefix,Head,NewBody,RuleList,BridgeRule), - get_canonical_form(Head,FLCANON(_,_,_,_,FL_TABLED)), + %%get_canonical_form(Head,FLCANON(_,_,_,_,FL_TABLED)), FLLIBUNIVEQFORM(NewBody,Body). matching_rule_signature(Prefix,FL_HASHED(Head),Body,(Prefix,Head,NewBody,RuleList,BridgeRule)) :- @@ -627,10 +627,28 @@ get_canonical_form(Head,FLCANON(_,_,_,_,FL_NOTTABLED)), FLLIBUNIVEQFORM(NewBody,Body). +matching_rule_signature(Prefix,FL_EXCL(Head),Body,(Prefix,Head,NewBody,RuleList,BridgeRule)) :- + var(Head), + !, + flora_rule_signature(Prefix,Head,NewBody,RuleList,BridgeRule), + get_canonical_form(Head,FLCANON(_,_,_,_,FL_TABLED)), + FLLIBUNIVEQFORM(NewBody,Body). + matching_rule_signature(Prefix,FL_HASHED(Head),Body,RuleSig) :- !, - matching_rule_signature(Prefix,Head,Body,RuleSig). + ( flora_is_nontabled_predicate(Head) -> + matching_rule_signature(Prefix,Head,Body,RuleSig) + ; + flora_abort("non-tabled predicate expected") + ). +matching_rule_signature(Prefix,FL_EXCL(Head),Body,RuleSig) :- + !, + ( flora_is_tabled_predicate(Head) -> + matching_rule_signature(Prefix,Head,Body,RuleSig) + ; + flora_abort("tabled predicate expected") + ). matching_rule_signature(Prefix,Head,Body,(Prefix,NewHead,NewBody,RuleList,BridgeRule)) :- (Head=','(_,_);Head=FLLIBMODLIT(_,_,_,_)), !, |
|
From: Chang Z. <ch...@us...> - 2005-03-21 22:38:43
|
Update of /cvsroot/flora/flora2/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23111/docs Modified Files: flora2.tex Log Message: introduce !-prefixed variables for tabled predicates Index: flora2.tex =================================================================== RCS file: /cvsroot/flora/flora2/docs/flora2.tex,v retrieving revision 1.124 retrieving revision 1.125 diff -u -d -r1.124 -r1.125 --- flora2.tex 20 Mar 2005 08:49:04 -0000 1.124 +++ flora2.tex 21 Mar 2005 22:38:33 -0000 1.125 @@ -3276,17 +3276,25 @@ \index{HiLog} % -HiLog \cite{hilog-jlp} is the default syntax that \FLORA uses to represent -functor terms (including object Ids) and predicates. In HiLog, complex -terms can appear wherever a function symbol is allowed. For example, {\tt - group(X)(Y,Z)} is a HiLog term where the functor is no longer a symbol -but rather a complex term {\tt group(X)}. Variables in HiLog can range over -terms, predicate and function symbols, and even over atomic formulas. For -instance, +HiLog \cite{hilog-jlp} is the default syntax that \FLORA uses to +represent functor terms (including object Ids) and predicates. In +HiLog, complex terms can appear wherever a function symbol is +allowed. For example, {\tt group(X)(Y,Z)} is a HiLog term where the +functor is no longer a symbol but rather a complex term {\tt +group(X)}. Variables in HiLog can range over terms, predicate and +function symbols, and even over atomic formulas. However, when a +variable appears as a predicate symbol, it has to be prefixed with +``\verb|!|'' or ``\verb|#|'' to indicate whether the HiLog predicate is +tabled or not, respectively. We will always assume that tabled HiLog +predicates are intended and thus use the ``\verb|!|'' prefix for such +variables until Section~\ref{sec-tabling-flora} which discusses tabling +in \FLORA. + +For instance, %% \[ {\tt - ?- p(X), X(p). + ?- p(X), !X(p). } \] %% @@ -3295,7 +3303,7 @@ %% \begin{equation}\label{eq-hilog-notallowed} {\tt - ?- p(X),~X(p),~X. + ?- p(X), ~!X(p), ~X. } \end{equation} %% @@ -3356,7 +3364,7 @@ \emph{will} work and produce a binding {\tt a(b)} for {\tt X}. %% \begin{verbatim} - flora2 ?- p(X),X(p),X@ _@. + flora2 ?- p(X), !X(p), !X@ _@. \end{verbatim} %% @@ -3388,8 +3396,8 @@ \begin{quote} p. \\ q().\\ - ?- p(), X().\\ - ?- q, X().\\ + ?- p(), !X().\\ + ?- q, !X().\\ ?- r = r(). \end{quote} } @@ -3556,11 +3564,21 @@ %% \begin{quote} \begin{verbatim} +?- X ~ p@M, Y ~ p@foo, pp(${X@_M1}) ~ pp(${Y@_M2}). +\end{verbatim} +\end{quote} +%% +Notice that the following query still fails because reification does not +have any effect if the reified formula is a variable and therefore the +query is the same as the one without reification. +%% +\begin{quote} +\begin{verbatim} ?- X ~ p@M, Y ~ p@foo, pp(${X}) ~ pp(${Y}). \end{verbatim} \end{quote} %% - + \subsection{Reification} \label{sec-reification} @@ -3669,14 +3687,14 @@ For instance, %% \begin{verbatim} - flora2 ?- a[b->X]@M ~ Y[b->d]@foo. + flora2 ?- p(${a[b->X]@M}) ~ p(${Y[b->d]@foo}). \end{verbatim} %% will return \emph{true}, because the two molecules are structurally similar and thus meta-unify. On the other hand, %% \begin{verbatim} - flora2 ?- ${a[b->X]@M} = ${Y[b->d]@foo}. + flora2 ?- ${p(${a[b->X]@M})} = ${p(${Y[b->d]@foo})}. \end{verbatim} %% will be false, because {\tt a[b->Y]@X} and {\tt Z[b->d]@foo} have different @@ -3685,10 +3703,10 @@ first-order sense). Note, however, that the queries %% \begin{verbatim} - ?- ${a[b->Y]@foo} = ${Z[b->d]@foo}. - ?- M=foo, ${a[b->Y]@M} = ${Z[b->d]@M}. - ?- a[b->Y]@foo ~ Z[b->d]@foo. - ?- M=foo, a[b->Y]@M ~ Z[b->d]@M. + ?- ${p(${a[b->Y]@foo})} = ${p(${Z[b->d]@foo})}. + ?- M=foo, ${p(${a[b->Y]@M})} = ${p(${Z[b->d]@M})}. + ?- p(${a[b->Y]@foo}) ~ p(${Z[b->d]@foo}). + ?- M=foo, p(${a[b->Y]@M}) ~ p(${Z[b->d]@M}). \end{verbatim} %% will all return \emph{true}, because {\tt a[b->Y]@foo} and {\tt @@ -4892,16 +4910,47 @@ \end{quote} %% +A predicate with the \verb|#| prefix is logically unrelated to the +predicate without the \verb|#| prefix. Thus, {\tt p(a)(b)} being true does +not mean that {\tt \verb|#|p(a)(b)} is true, and vice versa. + +When the predicate name is a variable, it is not clear whether the user +means tabled or non-tabled predicate. For this reason, we introduce +variables prefixed with the ``\verb|!|'' sign for tabled predicates as a +counterpart for variables prefixed with ``\verb|#|''. Therefore the +following are legal +%% +\begin{quote} +\begin{verbatim} +?- #X(a). // non-tabled +?- #p(a). // non-tabled +?- !X(a). // tabled +?- p(a). // tabled +\end{verbatim} +\end{quote} +%% +but the following are not: +%% +\begin{quote} +\begin{verbatim} +?- X(a). // ambiguity +?- !p(a). // ! is only allowed before variables +\end{verbatim} +\end{quote} +%% + Identifiers and variables that are prefixed with the ``\verb|#|'' sign -can appear only -as predicate formulas, predicate names, or procedural Boolean method names. The -following occurrences of ``\verb|#|'' are legal +can appear only as predicate formulas, predicate names, or procedural +Boolean method names. Variables prefixed with ``\verb|!|'' can appear +only as predicate formulas or predicates names. The following +occurrences of ``\verb|#|'' and ``\verb|!|'' are legal %% \begin{quote} \begin{verbatim} -?- insert{#p(a)}, #_(X). // #_ is a variable -?- a[#b(c)]. // #b is a procedural Boolean method -?- #X ~ #p(a). // #X is a variable, #p is a non-tabled predicate +?- insert{#p(a)}, #_(X), !X(Y). // #_ is a variable. #_ and !X are predicate names +?- a[#b(c)], a[#Y]. // #b and #Y are procedural Boolean methods +?- #X ~ #p(a). // #X is a variable, #p is a non-tabled predicate +?- !X ~ p(a). // !X is a variable \end{verbatim} \end{quote} %% @@ -4912,45 +4961,48 @@ ?- p(#a). // #a appears as a term, not formula ?- X = #a. // #a appears as a term, not formula ?- #X = a. // #X appears as a term, not formula +?- !X = a. // !X appears as a term, not formula ?- a[#b(c)->d]. // #b is not a Boolean method +?- a[!Y]. // !Y is not allowed as method \end{verbatim} \end{quote} %% -The first formula is illegal because {\tt \#a} occurs as a term and not as -a predicate (it can be made legal by reification, however: {\tt - p(\$\{\#a\})}). In the second and third formulas {\tt \#a} and {\tt \#X} -likewise appear as unreified terms. The last formula is illegal because -{\tt \#b(c)} is not a Boolean method. - -A predicate with the \verb|#| prefix is logically unrelated to the -predicate without the \verb|#| prefix. Thus, {\tt p(a)(b)} being true does -not mean that {\tt \verb|#|p(a)(b)} is true, and vice versa. +The first formula is illegal because {\tt \#a} occurs as a term and not +as a predicate (it can be made legal by reification, however: {\tt +p(\$\{\#a\})}). In the second, third and fourth formulas {\tt \#a}, {\tt +\#X} and {\tt !X} likewise appear as unreified terms. The fifth +formula is illegal because {\tt \#b(c)} is not a Boolean method. The +last formula is illegal because variables prefixed with ``\verb|!|'' are +not allowed as methods. -Occurrences of variables that are prefixed with a {\tt \#} are treated -specially. First, it should be kept in mind that {\tt \#X} and {\tt X} -represent the same variable. If {\tt X} is \emph{already bound} to -something then {\tt \#X} and {\tt X} mean the same thing. -Thus the following queries succeed because $\tt X \sim p(a)$ also binds -{\tt \#X} to {\tt p(a)} in the first query and, similarly, $\tt \#X \sim -a[\#b]$ in the second query determines the binding for {\tt X}. +Occurrences of variables that are prefixed with {\tt \#} or {\tt !} are +treated specially. First, it should be kept in mind that {\tt \#X}, +{\tt !X} and {\tt X} represent the same variable. If {\tt X} is +\emph{already bound} to something then all three of them mean the same +thing. However, {\tt X} can range over not only predicates but also +terms, conjunction of predicates, and even rules. {\tt \#X} can be +bound to only non-tabled predicates and {\tt !X} can be bound to only +tabled predicates. Thus error messages ``non-tabled predicate +expected'' and ``tabled predicate expected'' are issued for the +following two queries, respectively. %% \begin{quote} \begin{verbatim} ?- X ~ p(a), #X ~ p(a). -?- #X ~ a[#b], X ~ a[#b]. +?- X ~ a[#b], !X ~ a[#b]. \end{verbatim} \end{quote} %% -The following queries fail for similar reasons: in each case the first -literal determines the binding for {\tt \#X} or {\tt X}, and this binding -does not match with the expression on the right side of $\sim$ in the -second literal. +The following queries fail for the reason that {\tt \#X}, {\tt !X} and +{\tt X} represent the same variable: in each case the first literal +determines the binding for {\tt X}, and this binding does not match with +the expression on the right side of $\sim$ in the second literal. %% \begin{quote} \begin{verbatim} -?- X ~ p(a), #X ~ #p(a). -?- X = p(a), #X ~ #p(a). -?- #X ~ #p(a), X ~ p(a). +?- #X ~ #p(a), X ~ p(a). +?- !X ~ p(a), X = p(a). +?- !X ~ p(a), X ~ #p(a). \end{verbatim} \end{quote} %% @@ -4959,125 +5011,134 @@ the following rules apply: %% \begin{itemize} - \item If {\tt X} or {\tt \#X} is bound to a predicate or molecule - formula (tabled or non-tabled), then {\tt X@module} has the same meaning - as {\tt X}, and similarly for {\tt \#X}. That is, if the binding is - already a formula (and thus its module is already specified in it) then - the additional explicit module specification is discarded. -\item If {\tt X} or {\tt \#X} is bound to a HiLog \emph{term} (not a - predicate), e.g., {\tt p(a)(Z)}, then {\tt X@module} represents the tabled + \item If {\tt X} or {\tt \#X} or {\tt !X} is bound to a predicate or + molecule formula (tabled or non-tabled), then {\tt X@module} has the + same meaning as {\tt X}, and similarly for {\tt \#X} and {\tt + !X}. That is, if the binding is already a formula (and thus its + module is already specified in it) then the additional explicit module + specification is discarded. +\item If {\tt !X} or {\tt \#X} is bound to a HiLog \emph{term} (not a + predicate), e.g., {\tt p(a)(Z)}, then {\tt !X@module} represents the tabled predicate {\tt p(a)(Z)@module}. Similarly, {\tt \#X@module} represents - the non-tabled predicate {\tt \#p(a)(Z)@module}. + the non-tabled predicate {\tt \#p(a)(Z)@module}. {\tt X@module} will + give an error because it is not clear whether the tabled or non-tabled + predicate is intended. \end{itemize} %% -Due to these rules, the first query below succeeds, while the second fails. +Due to these rules, the first query below succeeds, while the second +fails and the third gives an error. %% \begin{verbatim} - flora2 ?- X = p(a), #X@M ~ #p(a). - flora2 ?- X ~ p(a)@main, #X@main ~ #p(a). + flora2 ?- X = p(a), #X@M ~ #p(a), !X@N ~ p(a)@foo. + flora2 ?- X ~ p(a), !X@M ~ p(a)@foo. + flora2 ?- X = p(a), X@M ~ p(a)@foo. \end{verbatim} %% The first query succeeds because {\tt X} is bound to a term, which {\tt \#X@M} converts to a non-tabled predicate with yet-to-be-determined -module. The meta-unification that follows therefore binds {\tt M} to {\tt - main}. The second query fails because {\tt X} is already bound to a -tables predicate and therefore {\tt \#X@main} represents {\tt p(a)@main}. -This does not meta-unify with a non-tabled predicate {\tt \#p(a)}. - + module. The meta-unification that follows therefore binds {\tt M} to + {\tt main}. Similarly {\tt !X@N} converts the term to a tabled + predicate and the meta-unification binds {\tt N} to {\tt foo}. The + second query fails because {\tt X} is already bound to a tabled + predicate and therefore {\tt !X@M} represents {\tt p(a)@main}, which + does not meta-unify with {\tt p(a)@foo}. The third query gives an + error because {\tt X@M} does not specify to convert the term to a + tabled predicate or a non-tabled one. -When {\tt X} (and thus {\tt \#X}) is \emph{unbound} then the occurrences of -{\tt \#X} indicate that {\tt X} is expected to be bound only to predicate -names, Boolean method names, or predicate/molecular formulas that -correspond to non-tabled methods or predicates. Likewise, an occurrence of -an unbound {\tt X} (without a {\tt \#}) indicates that {\tt X} is expected -to be bound to a tabled predicate or molecule. +When {\tt !X} (and thus {\tt \#X}) is \emph{unbound} then the +occurrences of {\tt \#X} indicate that {\tt X} is expected to be bound +only to predicate names, Boolean method names, or predicate/molecular +formulas that correspond to non-tabled methods or predicates. Likewise, +an occurrence of an unbound {\tt !X} indicates that {\tt X} is expected +to be bound to predicate names or predicate/molecular formulas that +correspond to tabled methods or predicates. -\paragraph{\#-prefixed variables and meta-programming.} -Variables that are prefixed with a {\tt \#} to indicate non-tabled -occurrences behave specially in meta-unifications, update operations and -the {\tt clause} construct. +\paragraph{\#-prefixed or !-prefixed variables and meta-programming.} +Variables that are prefixed with a {\tt \#} (or {\tt !}) to indicate +non-tabled (or tabled) occurrences behave specially in +meta-unifications, update operations and the {\tt clause} construct. The following is an example illustrating meta-unification of non-tabled predicates with unbound variables. %% \begin{quote} \begin{verbatim} flora2 ?- #X ~ #p(a). +flora2 ?- !X ~ p(a). flora2 ?- #X ~ p(a). +flora2 ?- !X ~ #p(a). \end{verbatim} \end{quote} %% -The first query succeeds with {\tt X} bound to -the non-tabled predicate {\tt \verb|#|p(a)}. -The second query fails because {\tt \verb|#|X} expects to be meta-unified -only with a non-tabled predicate or method. +The first two queries succeed with {\tt X} bound to the non-tabled +predicate {\tt \verb|#|p(a)} in the first query and tabled predicate +{\tt p(a)} in the second query. The last two queries fail because {\tt +\verb|#|X} expects to be meta-unified only with a non-tabled predicate +or method and {\tt \verb|!|X} expects to be meta-unified only with a +tabled predicate or method. + +Unbound {\tt X} can meta-unify with both tabled and non-tabled +predicates. Therefore the following queries all succeed. -For unbound {\tt X} or {\tt \verb|#|X}, it is not clear what such variables -should unify with. One possibility is to allow {\tt X} to meta-unify with -only tabled predicates or methods while {\tt \verb|#|X} with only -non-tabled predicates. To solve this dilemma, \FLORA allows {\tt X} to -meta-unify with anything but {\tt \verb|#|X} can unify only with non-tabled -predicates. Adding a module specification to {\tt X} limits it to only -tabled predicates. This can be seen from the following examples: %% \begin{quote} \begin{verbatim} -?- X ~ #p(a). // Yes -?- X ~ p(a). // Yes -?- X ~ a[b->c]@foo. // Yes -?- X ~ a[#b]@M. // Yes -?- X@M ~ #p(a). // No -?- X@foo ~ a[#b]@M. // No -?- #X ~ #p(a). // Yes -?- #X ~ p(a). // No +?- X ~ #p(a). +?- X ~ p(a). +?- X ~ a[b->c]@foo. +?- X ~ a[#b]@M. +?- X@M ~ p(a). +?- X@foo ~ a[#b]@M. \end{verbatim} \end{quote} %% -In the context of update operations, we know that we are dealing with only -predicates and methods. We can therefore use {\tt X} for tabled -predicates and {\tt \verb|#|X} for non-tabled predicates without any -ambiguity. The following example shows this. +In the context of update operations, we have the same rules: {\tt \#X} + for non-tabled predicates, {\tt !X} for tabled predicates and {\tt X} + for both. The following example shows this. %% \begin{quote} \begin{verbatim} -?- insert{p(a),#q(b)}. //Yes -?- delete{X}. //Yes with X = ${p(a)} -?- delete{X}. //No -?- delete{#X}. //Yes with X = ${#q(b)} +?- insert{p(a),#q(b)}. //Yes +?- delete{!X}. //Yes with X = ${p(a)} +?- delete{#X}. //Yes with X = ${#q(b)} +?- insert{p(a),#q(b)}. //Yes +?- delete{X}. //Yes with X non-determinstically bound to ${p(a)} or ${#q(b)} \end{verbatim} \end{quote} %% -For reified formulas that appear as predicate arguments, \FLORA -uses {\tt \$\{X\}} to -denote tabled predicates, {\tt \$\{\verb|#|X\}} to denote non-tabled -predicates, and a variable to unify with anything. +These rules also apply to querying rule bases with {\tt clause} or +deleting rules with {\tt deleterule}. + %% \begin{quote} \begin{verbatim} -?- insert{p(${a}),p(${#b})}. //Yes -?- p(${X}). //Yes with X = ${a} -?- p(${#X@M}). //Yes with X = ${#b} and M = main -?- p(X). //Yes with X = ${a} or ${#b} +?- insertrule{p(X) :- q(X)}. +?- insertrule{#t(X) :- #r(X)}. +?- insertrule{pp(X) :- q(X), #r(X)}. +?- clause{X,Y}. // all three rules match +?- clause{#X,Y}. // X = #t(_var) and Y = #r(_var) +?- clause{!X,!Y}. // X = p(_var) and Y = q(_var) +?- clause{!X,Y}. // the first and third match \end{verbatim} \end{quote} %% - -When querying rule bases with {\tt clause} or deleting rules with {\tt - deleterule}, variables that represent the head of a rule are treated the -same way as those in database operations {\tt insert} and {\tt delete}. In -contrast, variables that are supposed to match the body literals are -treated the same way as variables in meta-unifications. + +For reified formulas that appear as predicate arguments, \FLORA uses +{\tt \$\{!X\}} to denote tabled predicates, {\tt \$\{\verb|#|X\}} to +denote non-tabled predicates, and {\tt \$\{X\}} or simply a variable +{\tt X} to unify with anything. %% \begin{quote} \begin{verbatim} -?- insertrule{p(X) :- q(X)}. -?- insertrule{#t(X) :- #r(X)}. -?- clause{X,Y}. // X = p(_var) and Y = p(_var) -?- clause{#X,Y}. // X = #t(_var) and Y = #r(_var) +?- insert{p(${a}),p(${#b})}. //Yes +?- p(${!X}). //Yes with X = ${a} +?- p(${#X@M}). //Yes with X = ${#b} and M = main +?- p(X). //Yes with X = ${a} or ${#b} \end{verbatim} \end{quote} %% + %% Unimplemented -- Flora and subsumptive tabling |
|
From: Chang Z. <ch...@us...> - 2005-03-21 22:36:10
|
Update of /cvsroot/flora/flora-testsuite/general_tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22791/general_tests Modified Files: hashtest.flr Log Message: introduce !-prefixed variables for tabled predicates Index: hashtest.flr =================================================================== RCS file: /cvsroot/flora/flora-testsuite/general_tests/hashtest.flr,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- hashtest.flr 21 Mar 2005 06:52:16 -0000 1.2 +++ hashtest.flr 21 Mar 2005 22:36:00 -0000 1.3 @@ -43,7 +43,7 @@ #tst13 :- clause{dynamic,#X,Y}, write('tst13 succeeded, as expected = ')@prolog(), flora_write_goal(ans(X,Y))@prolog(flrdecode), nl@prolog(). -#tst14 :- unless clause{dynamic,_X,#_Y} +#tst14 :- unless clause{dynamic,!_X,#_Y} do writeln('tst14 failed as expected')@prolog(). #tst15 :- unless clause{dynamic,#_X,!_Y@_M} do writeln('tst15 failed as expected')@prolog(). |
|
From: Chang Z. <ch...@us...> - 2005-03-21 06:55:10
|
Update of /cvsroot/flora/flora2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4343 Modified Files: flrcoder.P flrcompiler.P flrcomposer.P flrdependency.P flrlexer.P flrparser.P Log Message: introduce variables prefixed with ! for tabled predicates Index: flrcoder.P =================================================================== RCS file: /cvsroot/flora/flora2/flrcoder.P,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- flrcoder.P 2 Feb 2005 12:11:09 -0000 1.40 +++ flrcoder.P 21 Mar 2005 06:55:00 -0000 1.41 @@ -86,6 +86,7 @@ is_prhashednumber(PRHASHEDNUMBER(Number,I),Number,I). is_prvariable(PRVARIABLE(Name,I),Name,I). is_prhashedvariable(PRHASHEDVARIABLE(Name,I),Name,I). +is_prexclvariable(PREXCLVARIABLE(Name,I),Name,I). is_prstring(PRSTRING(String,I),String,I). is_prlist(PRLIST(L,T,I),L,T,I). is_prfdbstorage(PRFDBSTORAGE(PRATOM(WS,I)),USERMODULE,WS,I). @@ -448,6 +449,14 @@ put(0')). flora_write_struct(Term,_Prefix) :- + is_prexclvariable(Term,Name,_Index), + !, + flora_write_quoted_atom(FL_EXCL), + put(0'(), + flora_write_variable(Name), + put(0')). + +flora_write_struct(Term,_Prefix) :- is_prcallervar(Term), !, flora_write_atom(FLORA_HEADLIT_CALLER_VAR_NAME). @@ -969,7 +978,6 @@ PF=WRAP_HILOG, is_prlist(PArgs,[FObj|ObjList],[],_I) - %% Case of X@Y, where X is a variable ; is_prvariable(P,_VarName,_Index) -> PArgs = P, PF=FL_LIBMOD % this wrapper is ignored -- just a placeholder @@ -978,6 +986,10 @@ PArgs = P, PF=FL_LIBMOD % this wrapper is ignored -- just a placeholder + ; is_prexclvariable(P,_VarName,_Index) -> + PArgs = P, + PF=FL_LIBMOD % this wrapper is ignored -- just a placeholder + ; is_flogic(P,Wrap,Arity,ObjList), flora_concat_atoms([Prefix,Wrap],PF), @@ -1203,6 +1215,12 @@ flora_build_variable(Name,VarList,Var), Code=FL_HASHED(Var). +flora_build_struct(Term,_DWS,_Prefix,VarList,Code,(Code,Index)) :- + is_prexclvariable(Term,Name,Index), + !, + flora_build_variable(Name,VarList,Var), + Code=FL_EXCL(Var). + %% We don't display the value of the special caller variable in the shell. %% Instead, we bind all occurrences of this variable in a rule to the same var flora_build_struct(Term,_DWS,_Prefix,VarList,Code,(_V,NO_INDEX)) :- @@ -1647,7 +1665,6 @@ PF=WRAP_HILOG, is_prlist(PArgs,[FObj|ObjList],[],NO_INDEX) - %% Case of X@Y, where X is a variable ; is_prvariable(P,_VarName,_Index) -> PArgs = P, %% this particular wrapper is ignored in fllibmodlit/4 @@ -1658,6 +1675,11 @@ %% this particular wrapper is ignored in fllibmodlit/4 PF=FL_LIBMOD + ; is_prexclvariable(P,_VarName,_Index) -> + PArgs = P, + %% this particular wrapper is ignored in fllibmodlit/4 + PF=FL_LIBMOD + ; is_flogic(P,Wrap,Arity,ObjList), flora_concat_atoms([Prefix,Wrap],PF), Index: flrcompiler.P =================================================================== RCS file: /cvsroot/flora/flora2/flrcompiler.P,v retrieving revision 1.67 retrieving revision 1.68 diff -u -d -r1.67 -r1.68 --- flrcompiler.P 2 Feb 2005 12:11:09 -0000 1.67 +++ flrcompiler.P 21 Mar 2005 06:55:00 -0000 1.68 @@ -187,6 +187,7 @@ is_flvar(FLVAR(Name,Index),Name,Index). is_flhashedvar(FLHASHEDVAR(Name,Index),Name,Index). +is_flexclvar(FLEXCLVAR(Name,Index),Name,Index). is_fllist(FLLIST(L,T,I),L,T,I). is_isaspecop(FL_ISA). @@ -349,6 +350,9 @@ hashedvarobj_struct(Name,Index,PRVARIABLE(Name,Index)). hashedvar_struct(Name,Index,PRHASHEDVARIABLE(Name,Index)). +exclvarobj_struct(Name,Index,PRVARIABLE(Name,Index)). +exclvar_struct(Name,Index,PREXCLVARIABLE(Name,Index)). + strobj_struct(FLSTRING(String,I),PRSTRING(String,I)). hashedstrobj_struct(FLHASHEDSTRING(String,I),PRSTRING(String,I)). newoid_struct(Oid,Index,PRNEWOID(Oid,Index)). @@ -507,7 +511,8 @@ %% X@module or X@flora(module) %% or #X@module or #X@flora(module) - ; (is_varobj_struct(P,Index); is_hashedvar_struct(P,Index)) -> + %% or !X@module or !X@flora(module) + ; (is_varobj_struct(P,Index); is_hashedvar_struct(P,Index); is_exclvar_struct(P,Index)) -> compile_workspace_term(WS,WSCode), set_context(literal_workspace(WS)), callerargsterm_struct(ThisModuleName,CallerInfo), @@ -976,6 +981,20 @@ flora_concat_atoms([NEWVAR,OldValAtm],Name), hashedvar_struct(Name,Index,VarObj). +new_exclvarobj(Index,VarObj) :- + flora_increment_counter(NEWVAR,1,OldVal,_NewVal), + number_codes(OldVal,OldValLst), + atom_codes(OldValAtm,OldValLst), + flora_concat_atoms([NEWVAR,OldValAtm],Name), + exclvarobj_struct(Name,Index,VarObj). + +new_exclvar(Index,VarObj) :- + flora_increment_counter(NEWVAR,1,OldVal,_NewVal), + number_codes(OldVal,OldValLst), + atom_codes(OldValAtm,OldValLst), + flora_concat_atoms([NEWVAR,OldValAtm],Name), + exclvar_struct(Name,Index,VarObj). + new_varobjlist(0,[]) :- !. @@ -1034,6 +1053,7 @@ is_varobj_struct(PRVARIABLE(_Name,Index),Index). is_strobj_struct(PRSTRING(_String,_I)). is_hashedvar_struct(PRHASHEDVARIABLE(_Name,Index),Index). +is_exclvar_struct(PREXCLVARIABLE(_Name,Index),Index). allvars(Term,Vars) :- allvars(Term,Vs,[]), @@ -1105,6 +1125,11 @@ !, is_flvar(NewParserTerm,Name,Index). +collect_vars(ParserTerm,[NewParserTerm|Vars],Vars) :- + is_flexclvar(ParserTerm,Name,Index), + !, + is_flvar(NewParserTerm,Name,Index). + collect_vars(ParserTerm,Vars,Vars) :- ( is_flatom(ParserTerm,_Atom); is_flhashedatom(ParserTerm,_Atom); @@ -1130,13 +1155,13 @@ subtract_vars([],_,[]) :- !. subtract_vars([H|T1],L,[H|T2]) :- - (is_flvar(H,FL_UNDERSCORE,_I);is_flhashedvar(H,FL_UNDERSCORE,_I)), + (is_flvar(H,FL_UNDERSCORE,_I);is_flhashedvar(H,FL_UNDERSCORE,_I);is_flexclvar(H,FL_UNDERSCORE,_I)), !, subtract_vars(T1,L,T2). subtract_vars([H|T],L,V) :- - (is_flvar(H,N,_I);is_flhashedvar(H,N,_I)), - (is_flvar(X,N,_J);is_flhashedvar(X,N,_J)), + (is_flvar(H,N,_I);is_flhashedvar(H,N,_I);is_flexclvar(H,N,_I)), + (is_flvar(X,N,_J);is_flhashedvar(X,N,_J);is_flexclvar(H,N,_I)), member(X,L), !, subtract_vars(T,L,V). @@ -1165,8 +1190,10 @@ indexvars([],[]) :- !. indexvars([T|L],Vars) :- - (is_flvar(T,Name,I);is_flhashedvar(T,Name,I)), - ( (is_flvar(T,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0);is_flhashedvar(T,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0)) -> + (is_flvar(T,Name,I);is_flhashedvar(T,Name,I);is_flexclvar(T,Name,I)), + ( (is_flvar(T,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0); + is_flhashedvar(T,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0); + is_flexclvar(T,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0))-> indexvars(L,Vars) ; Vars=[I-Name|Vs], @@ -1196,14 +1223,14 @@ singleton_vars([],[]) :- !. singleton_vars([V|L],[V|Vs]) :- - (is_flvar(V,FL_UNDERSCORE,_I);is_flhashedvar(V,FL_UNDERSCORE,_I)), + (is_flvar(V,FL_UNDERSCORE,_I);is_flhashedvar(V,FL_UNDERSCORE,_I);is_flexclvar(V,FL_UNDERSCORE,_I)), !, singleton_vars(L,Vs). singleton_vars([V],[V]) :- !. singleton_vars([V1,V2|L],Vars) :- - ( (is_flvar(V1,Name,_I);is_flhashedvar(V1,Name,_I)), (is_flvar(V2,Name,_J);is_flhashedvar(V2,Name,_I)) -> + ( (is_flvar(V1,Name,_I);is_flhashedvar(V1,Name,_I);is_flexclvar(V1,Name,_I)), (is_flvar(V2,Name,_J);is_flhashedvar(V2,Name,_J);is_flexclvar(V2,Name,_J)) -> remove_dupvars(L,Name,Vs), singleton_vars(Vs,Vars) ; @@ -1213,7 +1240,7 @@ remove_dupvars([V|L],Name,Vars) :- - (is_flvar(V,Name,_I);is_flhashedvar(V,Name,_I)), + (is_flvar(V,Name,_I);is_flhashedvar(V,Name,_I);is_flexclvar(V,Name,_I)), !, remove_dupvars(L,Name,Vars). @@ -1227,8 +1254,10 @@ singleton_warning([],WarnList,WarnList). singleton_warning([V|L],WarnList,WarnTail) :- - (is_flvar(V,Name,I);is_flhashedvar(V,Name,I)), - ( (is_flvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0);is_flhashedvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0)) -> + (is_flvar(V,Name,I);is_flhashedvar(V,Name,I);is_flexclvar(V,Name,I)), + ( (is_flvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0); + is_flhashedvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0); + is_flexclvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0))-> singleton_warning(L,WarnList,WarnTail) ; compiling_warning(I,SINGLETON_VAR,W), @@ -1244,8 +1273,10 @@ unbound_warning([],WarnList,WarnList). unbound_warning([V|L],WarnList,WarnTail) :- - (is_flvar(V,Name,I);is_flhashedvar(V,Name,I)), - ( (is_flvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0);is_flhashedvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0)) -> + (is_flvar(V,Name,I);is_flhashedvar(V,Name,I);is_flexclvar(V,Name,I)), + ( (is_flvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0); + is_flhashedvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0); + is_flexclvar(V,Name,I),flora_match_substring(FL_UNDERSCORE,Name,0))-> unbound_warning(L,WarnList,WarnTail) ; compiling_warning(I,UNBOUND_VAR,W), @@ -1826,7 +1857,11 @@ compile_head_literal(ParserTerm,Code,Status) :- set_context(compiling_headliteral), ( is_flvar(ParserTerm,VName,VIndex) -> - compile_flvar(VName,VIndex,V), + compile_flvar(VName,VIndex,Code), + Status=[] + + ; is_flhashedvar(ParserTerm,VName,VIndex) -> + compile_flhashedvar(VName,VIndex,V), ( COMPILATION_CONTEXT(compile_with_var_module), \+ COMPILATION_CONTEXT(goal_reification) -> Code = V ; @@ -1837,8 +1872,8 @@ ), Status=[] - ; is_flhashedvar(ParserTerm,VName,VIndex) -> - compile_flhashedvar(VName,VIndex,V), + ; is_flexclvar(ParserTerm,VName,VIndex) -> + compile_flexclvar(VName,VIndex,V), ( COMPILATION_CONTEXT(compile_with_var_module), \+ COMPILATION_CONTEXT(goal_reification) -> Code = V ; @@ -1940,7 +1975,7 @@ ), ( is_flvar(ParserTerm,VName,VIndex) -> compile_flvar(VName,VIndex,V), - ( COMPILATION_CONTEXT(compile_with_var_module), \+ COMPILATION_CONTEXT(goal_reification) -> + ( (COMPILATION_CONTEXT(compile_with_var_module); COMPILATION_CONTEXT(goal_reification); COMPILATION_CONTEXT(compile_meta);COMPILATION_CONTEXT(compile_delete)) -> SpecCode = V ; thismodule_struct(ThisModule), @@ -1964,6 +1999,19 @@ OidCode=NULL, Status=[] + ; is_flexclvar(ParserTerm,VName,VIndex) -> + compile_flexclvar(VName,VIndex,V), + ( COMPILATION_CONTEXT(compile_with_var_module), \+ COMPILATION_CONTEXT(goal_reification) -> + SpecCode = V + ; + thismodule_struct(ThisModule), + callerargsterm_struct(ThisModule,CallerInfo), %% does not matter + atomobj_struct(FL_INVALIDMODULE,Module), + florasyslib_struct(VIndex,FLLIBMODLIT,3,[V,Module,CallerInfo],SpecCode) + ), + OidCode=NULL, + Status=[] + ; is_flterm(ParserTerm,Funct,N,Args) -> compile_fltermlit(Funct,N,Args,OidCode,SpecCode,Status) @@ -2130,7 +2178,8 @@ conjunct_code([SpecCode,OidCode],Code), clear_context(varpred_reify) ; - conjunct_code([OidCode,SpecCode],Code) + conjunct_code([OidCode,SpecCode],Code), + clear_context(compiling_prolog) ), (nonvar(PrevContext) -> set_context(PrevContext); true), (nonvar(PrologContext) -> set_context(PrologContext); true). @@ -2282,6 +2331,9 @@ ; is_flhashedvar(ParserTerm,Name,Index) -> compile_flhashedvar_without_hash(Name,Index,Object) + ; is_flexclvar(ParserTerm,Name,Index) -> + compile_flexclvar_without_excl(Name,Index,Object) + ; is_flstring(ParserTerm,_S) -> strobj_struct(ParserTerm,Object) @@ -2389,7 +2441,9 @@ %% Don't set compilation context to be 'goal_reification': %% These are special predicates such as findall, call, etc., %% for which we want to set the caller argument = current module + set_context(compile_meta), compile_body(T,TCode1,S), + clear_context(compile_meta), reify_struct(TCode1,TCode), ( S == [] -> compile_argpathexplist(L,ArgTypeList,LObj,OidCode,Code,Status) @@ -2445,6 +2499,20 @@ hashedvarobj_struct(Name,Index,VarObject) ). +compile_flexclvar(Name,Index,VarObject) :- + ( Name == FL_UNDERSCORE -> + new_exclvar(Index,VarObject) + ; + exclvar_struct(Name,Index,VarObject) + ). + +compile_flexclvar_without_excl(Name,Index,VarObject) :- + ( Name == FL_UNDERSCORE -> + new_exclvarobj(Index,VarObject) + ; + exclvarobj_struct(Name,Index,VarObject) + ). + compile_flhashedvar(Name,Index,VarObject) :- ( Name == FL_UNDERSCORE -> new_hashedvar(Index,VarObject) @@ -2676,31 +2744,58 @@ %% the attribute (M) and the value (V). We conjunct this code in front of the %% code for the molecule %% NULL means that we don't pass OID code out, because we use it right here. -compile_flspecbody(Object,SpecTerm,OidCode,Code,Status) :- +compile_flspecbody(Object,SpecTerm,NULL,Code,Status) :- is_flfdattspec(SpecTerm,AttTerm,RefType,ValTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_pathexplist([AttTerm,ValTerm],[AttObj,ValObj],OidCode,OCode,Status), ( Status == [] -> fdattspec_struct(BODYLITERAL,Object,AttObj,RefType,ValObj,SCode), %% SCode: code to produce object reference, attribute, and value %% OCode: code for the pure attribute spec of the object %% OidCode: code to produce the attribute and the value - conjunct_code([SCode,OCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([SCode,OCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,SCode,OCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% Same for ->> %% No OidCode is passed outside: we consume it here -compile_flspecbody(Object,SpecTerm,OidCode,Code,Status) :- +compile_flspecbody(Object,SpecTerm,NULL,Code,Status) :- is_flmvdattspec(SpecTerm,AttTerm,RefType,ValTermList), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_pathexp(AttTerm,AttObj,AOidCode,ACode,S), + (COMPILATION_CONTEXT(varpred_reify) -> + AContext = varpred_reify, + clear_context(varpred_reify) + ; + true + ), ( S == [] -> ( ValTermList == [] -> mvdattdef_struct(BODYLITERAL,Object,AttObj,RefType,SCode), - conjunct_code([ACode,SCode],Code), - OidCode = AOidCode, + (AContext == varpred_reify -> + conjunct_code([ACode,SCode,AOidCode],Code) + ; + conjunct_code([AOidCode,ACode,SCode],Code) + ), Status=[] ; %% An mvd spec can have several terms in the value set @@ -2711,26 +2806,54 @@ %% SCode: code to produce pure attr specs and %% the objects that represents the values (Status == [] -> - conjunct_code([AOidCode,VOidCode],OidCode), - conjunct_code([ACode,SCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + clear_context(varpred_reify), + (AContext == varpred_reify -> + conjunct_code([ACode,SCode,AOidCode,VOidCode],Code) + ; + conjunct_code([AOidCode,ACode,SCode,VOidCode],Code) + ) + ; + (AContext == varpred_reify -> + conjunct_code([VOidCode,ACode,SCode,AOidCode],Code) + ; + conjunct_code([AOidCode,VOidCode,ACode,SCode],Code) + ) + ) ; true ) ) ; Status=S - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% signatures: =>, *=>, etc. -compile_flspecbody(Object,SpecTerm,OidCode,Code,Status) :- +compile_flspecbody(Object,SpecTerm,NULL,Code,Status) :- is_flsigattspec(SpecTerm,AttTerm,RefType,ValTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_pathexp(AttTerm,AttObj,AOidCode,ACode,S), + (COMPILATION_CONTEXT(varpred_reify) -> + AContext = varpred_reify, + clear_context(varpred_reify) + ; + true + ), (S == [] -> (is_flemptyterm(ValTerm) -> sigattdef_struct(BODYLITERAL,Object,AttObj,RefType,SCode), - conjunct_code([ACode,SCode],Code), - OidCode = AOidCode, + (AContext == varpred_reify -> + conjunct_code([ACode,SCode,AOidCode],Code) + ; + conjunct_code([AOidCode,ACode,SCode],Code) + ), Status=[] ; compile_pathexp(ValTerm,ValObj,VOidCode,VCode,Status), @@ -2742,40 +2865,77 @@ %% ACode: code for the attribute %% VOidCode: code to produce value of the attribute %% VCode: code for value of the attribute - conjunct_code([ACode,VCode,SCode],Code), - conjunct_code([AOidCode,VOidCode],OidCode) + (COMPILATION_CONTEXT(varpred_reify) -> + clear_context(varpred_reify), + (AContext == varpred_reify -> + conjunct_code([ACode,VCode,SCode,AOidCode,VOidCode],Code) + ; + conjunct_code([AOidCode,ACode,VCode,SCode,VOidCode],Code) + ) + ; + (AContext == varpred_reify -> + conjunct_code([VOidCode,ACode,VCode,SCode,AOidCode],Code) + ; + conjunct_code([AOidCode,VOidCode,ACode,VCode,SCode],Code) + ) + ) ; true ) ) ; Status = S - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% +>>, *+>> -compile_flspecbody(Object,SpecTerm,OidCode,Code,Status) :- +compile_flspecbody(Object,SpecTerm,NULL,Code,Status) :- is_flincattspec(SpecTerm,AttTerm,RefType,ValTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_pathexplist([AttTerm,ValTerm],[AttObj,ValObj],OidCode,OCode,Status), ( Status == [] -> incattspec_struct(Object,AttObj,RefType,ValObj,SCode), - conjunct_code([SCode,OCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([SCode,OCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,SCode,OCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% same for ->-> -compile_flspecbody(Object,SpecTerm,OidCode,Code,Status) :- +compile_flspecbody(Object,SpecTerm,NULL,Code,Status) :- is_fltolistattspec(SpecTerm,AttTerm,RefType,ValTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_pathexplist([AttTerm,ValTerm],[AttObj,ValObj],OidCode,OCode,Status), ( Status == [] -> tolistattspec_struct(Object,AttObj,RefType,ValObj,SCode), %% Fold OidCode in front of the molecule - conjunct_code([SCode,OCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([SCode,OCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,SCode,OCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% Obj[true], Obj[fail], Obj[!] translate as true, fail, and ! compile_flspecbody(_Object,SpecTerm,NULL,Code,Status) :- @@ -2789,50 +2949,86 @@ Status=[]. %% Obj[X>Y], Obj[X=Y], etc. -compile_flspecbody(_Object,SpecTerm,OidCode,Code,Status) :- +compile_flspecbody(_Object,SpecTerm,NULL,Code,Status) :- is_flpassthru(SpecTerm,P), is_flterm(P, Funct, N, Args), !, - compile_prlgterm(Funct,N,Args,TCode,OidCode,ACode,Status), + compile_prlgterm(Funct,N,Args,TCode,_OidCode,ACode,Status), (Status == [] -> conjunct_code([ACode,TCode],Code); true). %% for O[BoolMeth] -compile_flspecbody(Object,SpecTerm,OidCode,Code,Status) :- +compile_flspecbody(Object,SpecTerm,NULL,Code,Status) :- is_flmethspec(SpecTerm,MethTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_pathexp(MethTerm,MethObj,OidCode,MCode,Status), ( Status == [] -> methspec_struct(BODYLITERAL,Object,MethObj,SCode), %% Fold OidCode in front of the molecule - conjunct_code([MCode,SCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([MCode,SCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,MCode,SCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% for O[*BoolMeth] -compile_flspecbody(Object,SpecTerm,OidCode,Code,Status) :- +compile_flspecbody(Object,SpecTerm,NULL,Code,Status) :- is_flimethspec(SpecTerm,IMethTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_pathexp(IMethTerm,IMethObj,OidCode,IMCode,Status), ( Status == [] -> imethspec_struct(BODYLITERAL,Object,IMethObj,SCode), %% Fold OidCode in front of the molecule - conjunct_code([IMCode,SCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([IMCode,SCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,IMCode,SCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% O[#M] -compile_flspecbody(Object,SpecTerm,OidCode,Code,Status) :- +compile_flspecbody(Object,SpecTerm,NULL,Code,Status) :- is_fltranspec(SpecTerm,TranTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_pathexp(TranTerm,TranObj,OidCode,TCode,Status), ( Status == [] -> transpec_struct(BODYLITERAL,Object,TranObj,SCode), - conjunct_code([TCode,SCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([TCode,SCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,TCode,SCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). /**************************************************************************** @@ -3093,7 +3289,9 @@ compile_head_argpathexplist([T|L],[FL_BODYFORMULA|ArgTypeList],[TCode|LObj],Code,Status) :- !, set_context(goal_reification), + set_context(compile_meta), compile_body(T,TCode1,S), + clear_context(compile_meta), reify_struct(TCode1,TCode), clear_context(goal_reification), ( S == [] -> @@ -3139,6 +3337,9 @@ ; is_flhashedvar(ParserTerm,Name,Index) -> compile_flhashedvar_without_hash(Name,Index,Object) + ; is_flexclvar(ParserTerm,Name,Index) -> + compile_flexclvar_without_excl(Name,Index,Object) + ; is_flstring(ParserTerm,_S) -> strobj_struct(ParserTerm,Object) @@ -3442,6 +3643,14 @@ OidCode = NULL, Status = [] + ; is_flexclvar(ParserTerm,VarName,Index) -> + %% Is this possible? Should be taken care by the libmodlit code + attach_workspace(WS, + compile_flexclvar(VarName,Index,VarCode), + VarCode,WSCode), + OidCode = NULL, + Status = [] + ; is_flbirelate(ParserTerm,ObjTerm1,RelType,ObjTerm2) -> compile_wsflbirelate(ObjTerm1,RelType,ObjTerm2,WS,_Obj,OidCode,WSCode,Status) @@ -3573,7 +3782,9 @@ %% workspace not distributive over nested "meta" %%compile_body(T,TCode,S), set_context(goal_reification), + set_context(compile_meta), compile_body(T,TCode1,S), + clear_context(compile_meta), reify_struct(TCode1,TCode), clear_context(goal_reification), ( S == [] -> @@ -3871,9 +4082,15 @@ %% the attribute (M) and the value (V). We conjunct this code in front of the %% code for the molecule %% NULL means tht we don't pass OID code out, because we use it right here. -compile_wsflspecbody(Object,SpecTerm,WS,OidCode,Code,Status) :- +compile_wsflspecbody(Object,SpecTerm,WS,NULL,Code,Status) :- is_flfdattspec(SpecTerm,AttTerm,RefType,ValTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_wsflpathexplist([AttTerm,ValTerm],WS,[AttObj,ValObj],OidCode,OCode,Status), ( Status == [] -> attach_workspace(WS, @@ -3882,24 +4099,45 @@ %% WSCode: code to produce object reference, attribute, and value %% OCode: code for the pure attribute spec of the object %% OidCode: code to produce the attribute and the value - conjunct_code([WSCode,OCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([WSCode,OCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,WSCode,OCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% No OidCode is passed outside: we consume it here -compile_wsflspecbody(Object,SpecTerm,WS,OidCode,Code,Status) :- +compile_wsflspecbody(Object,SpecTerm,WS,NULL,Code,Status) :- is_flmvdattspec(SpecTerm,AttTerm,RefType,ValTermList), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_wsflpathexp(AttTerm,WS,AttObj,AOidCode,ACode,S), + (COMPILATION_CONTEXT(varpred_reify) -> + AContext = varpred_reify, + clear_context(varpred_reify) + ; + true + ), ( S == [] -> ( ValTermList == [] -> attach_workspace(WS, mvdattdef_struct(BODYLITERAL,Object,AttObj,RefType,SCode), SCode,WSCode), %% Fold OidCode in front of molecule - conjunct_code([ACode,WSCode],Code), - OidCode = AOidCode, + (AContext == varpred_reify -> + conjunct_code([ACode,WSCode,AOidCode],Code) + ; + conjunct_code([AOidCode,ACode,WSCode],Code) + ), Status=[] ; compile_wsmvdattspec(Object,AttObj,RefType,ValTermList,WS,VOidCode,WSCode,Status), @@ -3907,27 +4145,55 @@ %% ACode: Code to produce attribute %% WSCode: code to produce pure attr specs and %% the objects that represents the values - conjunct_code([ACode,WSCode],Code), - conjunct_code([AOidCode,VOidCode],OidCode) + (COMPILATION_CONTEXT(varpred_reify) -> + clear_context(varpred_reify), + (AContext == varpred_reify -> + conjunct_code([ACode,WSCode,AOidCode,VOidCode],Code) + ; + conjunct_code([AOidCode,ACode,WSCode,VOidCode],Code) + ) + ; + (AContext == varpred_reify -> + conjunct_code([VOidCode,ACode,WSCode,AOidCode],Code) + ; + conjunct_code([AOidCode,VOidCode,ACode,WSCode],Code) + ) + ) ; true ) ) ; Status=S - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% signatures: =>, *=>, etc. -compile_wsflspecbody(Object,SpecTerm,WS,OidCode,Code,Status) :- +compile_wsflspecbody(Object,SpecTerm,WS,NULL,Code,Status) :- is_flsigattspec(SpecTerm,AttTerm,RefType,ValTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_wsflpathexp(AttTerm,WS,AttObj,AOidCode,ACode,S), + (COMPILATION_CONTEXT(varpred_reify) -> + AContext = varpred_reify, + clear_context(varpred_reify) + ; + true + ), (S == [] -> (is_flemptyterm(ValTerm) -> attach_workspace(WS, sigattdef_struct(BODYLITERAL,Object,AttObj,RefType,SCode), SCode,WSCode), - conjunct_code([ACode,WSCode],Code), - OidCode = AOidCode, + (AContext == varpred_reify -> + conjunct_code([ACode,WSCode,AOidCode],Code) + ; + conjunct_code([AOidCode,ACode,WSCode],Code) + ), Status=[] ; compile_wsflpathexp(ValTerm,WS,ValObj,VOidCode,VCode,Status), @@ -3935,47 +4201,83 @@ attach_workspace(WS, sigattspec_struct(BODYLITERAL,Object,AttObj,RefType,ValObj,SCode), SCode,WSCode), - conjunct_code([ACode,VCode,WSCode],Code), - conjunct_code([AOidCode,VOidCode],OidCode) + (COMPILATION_CONTEXT(varpred_reify) -> + clear_context(varpred_reify), + (AContext == varpred_reify -> + conjunct_code([ACode,VCode,WSCode,AOidCode,VOidCode],Code) + ; + conjunct_code([AOidCode,ACode,VCode,WSCode,VOidCode],Code) + ) + ; + (AContext == varpred_reify -> + conjunct_code([VOidCode,ACode,VCode,WSCode,AOidCode],Code) + ; + conjunct_code([AOidCode,VOidCode,ACode,VCode,WSCode],Code) + ) + ) ; true ) ) ; Status = S - ). - + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% +>>, *+>>@module %% NULL means: consume OidCode for attr and val here -- don't pass up the chain -compile_wsflspecbody(Object,SpecTerm,WS,OidCode,Code,Status) :- +compile_wsflspecbody(Object,SpecTerm,WS,NULL,Code,Status) :- is_flincattspec(SpecTerm,AttTerm,RefType,ValTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_wsflpathexplist([AttTerm,ValTerm],WS,[AttObj,ValObj],OidCode,OCode,Status), ( Status == [] -> attach_workspace(WS, incattspec_struct(Object,AttObj,RefType,ValObj,SCode), SCode,WSCode), %% Fold OidCode in front of molecule - conjunct_code([WSCode,OCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([WSCode,OCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,WSCode,OCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% same for ->->@module %% NULL means: consume OidCode for attr and val here -- don't pass up the chain -compile_wsflspecbody(Object,SpecTerm,WS,OidCode,Code,Status) :- +compile_wsflspecbody(Object,SpecTerm,WS,NULL,Code,Status) :- is_fltolistattspec(SpecTerm,AttTerm,RefType,ValTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_wsflpathexplist([AttTerm,ValTerm],WS,[AttObj,ValObj],OidCode,OCode,Status), ( Status == [] -> attach_workspace(WS, tolistattspec_struct(Object,AttObj,RefType,ValObj,SCode), SCode,WSCode), - conjunct_code([WSCode,OCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([WSCode,OCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,WSCode,OCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% Obj[true], Obj[fail], Obj[!] translate as true, fail, and ! compile_wsflspecbody(_Object,SpecTerm,_WS,NULL,Code,Status) :- @@ -3989,57 +4291,93 @@ Status=[]. %% Obj[X>Y], Obj[X=Y], etc. -compile_wsflspecbody(_Object,SpecTerm,_WS,OidCode,Code,Status) :- +compile_wsflspecbody(_Object,SpecTerm,_WS,NULL,Code,Status) :- is_flpassthru(SpecTerm,P), is_flterm(P, Funct, N, Args), !, - compile_prlgterm(Funct,N,Args,TCode,OidCode,ACode,Status), + compile_prlgterm(Funct,N,Args,TCode,_OidCode,ACode,Status), (Status == [] -> conjunct_code([ACode,TCode],Code); true). %% for O[BoolMeth]@module %% NULL means: consume OidCode for attr and val here -- don't pass up the chain -compile_wsflspecbody(Object,SpecTerm,WS,OidCode,Code,Status) :- +compile_wsflspecbody(Object,SpecTerm,WS,NULL,Code,Status) :- is_flmethspec(SpecTerm,MethTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_wsflpathexp(MethTerm,WS,MethObj,OidCode,MCode,Status), ( Status == [] -> attach_workspace(WS, methspec_struct(BODYLITERAL,Object,MethObj,SCode), SCode,WSCode), - conjunct_code([MCode,WSCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([MCode,WSCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,MCode,WSCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% for O[*BoolMeth]@module %% NULL means: consume OidCode for attr and val here -- don't pass up the chain -compile_wsflspecbody(Object,SpecTerm,WS,OidCode,Code,Status) :- +compile_wsflspecbody(Object,SpecTerm,WS,NULL,Code,Status) :- is_flimethspec(SpecTerm,IMethTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_wsflpathexp(IMethTerm,WS,IMethObj,OidCode,IMCode,Status), ( Status == [] -> attach_workspace(WS, imethspec_struct(BODYLITERAL,Object,IMethObj,SCode), SCode,WSCode), %% Fold OidCode in front of molecule - conjunct_code([IMCode,WSCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([IMCode,WSCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,IMCode,WSCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). %% O[#M]@module -compile_wsflspecbody(Object,SpecTerm,WS,OidCode,Code,Status) :- +compile_wsflspecbody(Object,SpecTerm,WS,NULL,Code,Status) :- is_fltranspec(SpecTerm,TranTerm), !, + (COMPILATION_CONTEXT(varpred_reify) -> + PrevContext=varpred_reify, + clear_context(varpred_reify) + ; + true + ), compile_wsflpathexp(TranTerm,WS,TranObj,OidCode,TCode,Status), ( Status == [] -> attach_workspace(WS, transpec_struct(BODYLITERAL,Object,TranObj,SCode), SCode,WSCode), - conjunct_code([TCode,WSCode],Code) + (COMPILATION_CONTEXT(varpred_reify) -> + conjunct_code([TCode,WSCode,OidCode],Code), + clear_context(varpred_reify) + ; + conjunct_code([OidCode,TCode,WSCode],Code) + ) ; true - ). + ), + (nonvar(PrevContext) -> set_context(PrevContext); true). /**************************************************************************** @@ -4426,6 +4764,12 @@ compile_flhashedvar(VarName,Index,VarCode), VarCode,Code), Status=[] + ; is_flexclvar(ParserTerm,VarName,Index) -> + %% Is this possible? Should be taken care by the libmodlit code + attach_workspace(WS, + compile_flexclvar(VarName,Index,VarCode), + VarCode,Code), + Status=[] ; attach_workspace(WS, atomlit_struct(HEADLITERAL,ParserTerm,ACode), @@ -4464,7 +4808,9 @@ %% workspace not distributive over nested `meta' argument spec %%compile_body(T,TCode,S), set_context(goal_reification), + clear_context(compile_meta), compile_body(T,TCode1,S), + clear_context(compile_meta), reify_struct(TCode1,TCode), clear_context(goal_reification), ( S == [] -> @@ -4986,7 +5332,9 @@ compile_fldelete_list([H|T],CodeList,Status) :- %% Call compile_body_literal because path expressions should be %% compiled into queries. + set_context(compile_delete), compile_body_literal(H,HCode,S), + clear_context(compile_delete), ( S == [] -> compile_conjunct2list(HCode,HCodeList), compile_fldelete_list(T,TCodeList,Status), Index: flrparser.P =================================================================== RCS file: /cvsroot/flora/flora2/flrparser.P,v retrieving revision 1.72 retrieving revision 1.73 diff -u -d -r1.72 -r1.73 --- flrparser.P 2 Feb 2005 12:11:09 -0000 1.72 +++ flrparser.P 21 Mar 2005 06:55:01 -0000 1.73 @@ -48,8 +48,9 @@ #define ALLOW_VARIABLES allow_variables #define DISALLOW_VARIABLES disallow_variables -#define ALLOW_HASH allow_hash -#define DISALLOW_HASH disallow_hash +#define DISALLOW_HASH disallow_hash %% neither # nor ! is allowed +#define ALLOW_HASH_NOPREFIX allow_hash_noprefix %% for method +#define ALLOW_HASH_EXCL allow_hash_excl %% predicate name %% If the module specification is for a dynamic rule (eg. foo in %% insertrule{(...)@foo}), the module information is just discarded when @@ -631,6 +632,8 @@ flhashedobject_struct(OBJECT(HASHED_VARIABLE(Name),I),FLHASHEDVAR(Name,I)) :- !. flhashedobject_struct(OBJECT(HASHED_ASCII_STRING(Str),I),FLHASHEDSTRING(Str,I)) :- !. +flexclobject_struct(OBJECT(EXCL_VARIABLE(Name),I),FLEXCLVAR(Name,I)) :- !. + flhashednumber_struct(OBJECT(HASHED_NUMBER(Num),I),FLHASHEDNUMBER(Num,I)) :- !. is_flhashedobject_struct(FLHASHEDATOM(_Atom,_I)) :- !. @@ -645,10 +648,13 @@ get_flvar_struct(OBJECT(VARIABLE(Name),I),FLVAR(Name,I)). get_flhashedvar_struct(OBJECT(HASHED_VARIABLE(Name),I),FLHASHEDVAR(Name,I)). +get_flexclvar_struct(OBJECT(EXCL_VARIABLE(Name),I),FLEXCLVAR(Name,I)). is_flvar_struct(FLVAR(_Name,_I)). is_flhashedvar_struct(FLHASHEDVAR(_Name,_I)). +is_flexclvar_struct(FLEXCLVAR(_Name,_I)). is_anonymous_flvar_struct(FLVAR(FL_UNDERSCORE,_I)). is_anonymous_flhashedvar_struct(FLHASHEDVAR(FL_UNDERSCORE,_I)). +is_anonymous_flexclvar_struct(FLEXCLVAR(FL_UNDERSCORE,_I)). fllist_struct(L,T,Index,FLLIST(L,T,Index)). is_fllist_struct(FLLIST(_L,_T,_I)). @@ -1222,6 +1228,9 @@ flexport_wrap_term(WS,WSFrom,OBJECT(HASHED_VARIABLE(Term),N),[],IsUpdatable,Code), !. +flora_export_compose_term([OBJECT(EXCL_VARIABLE(Term),N)],WS,WSFrom,IsUpdatable,Code) :- + flexport_wrap_term(WS,WSFrom,OBJECT(EXCL_VARIABLE(Term),N),[],IsUpdatable,Code), + !. /**************************************************************************** flora_export_wrap_multiple_terms(+WorkSpace,+WSFrom,+Args,+InitTermCode,+Modules,+IsUpdatable,-Code) Transfroms (t1,t2) >> (m1,m2,m3) --> [(t1,(m1,m2,m3)) , (t2,(m1,m2,m3))] @@ -1398,6 +1407,7 @@ %% Term >> m1, m2 flora_export_check_error(OBJECT(VARIABLE(_Term),_),_Status). flora_export_check_error(OBJECT(HASHED_VARIABLE(_Term),_),_Status). +flora_export_check_error(OBJECT(EXCL_VARIABLE(_Term),_),_Status). /**************************************************************************** @@ -1958,7 +1968,7 @@ flora_head_literal(CANOTERM(Funct,N,FL_PARENTHESIS,Args,_If,_Ip),Code,Status) :- !, - flora_head_term(Funct,N,Args,ALLOW_HASH,Code,Status). + flora_head_term(Funct,N,Args,ALLOW_HASH_EXCL,Code,Status). flora_head_literal(CANOTERM(Funct,N,FL_BRACKET,Args,_If,_Ip),Code,Status) :- !, @@ -2746,7 +2756,7 @@ flora_body_literal(CANOTERM(Funct,N,FL_PARENTHESIS,Args,_If,_Ip),Code,Status) :- !, - flora_term(Funct,N,Args,ALLOW_HASH,Code,Status). + flora_term(Funct,N,Args,ALLOW_HASH_EXCL,Code,Status). %% ...[...] flora_body_literal(CANOTERM(Funct,N,FL_BRACKET,Args,_If,_Ip),Code,Status) :- @@ -2793,17 +2803,8 @@ flhashedobject_struct(CanoniTerm,Code). flora_body_literal(CanoniTerm,Code,Status) :- - get_flvar_struct(CanoniTerm,C), - !, - ((PARSER_CONTEXT(parsing_facts);PARSER_CONTEXT(parsing_rulehead)) -> - parsing_error(CanoniTerm,NO_PRED_VAR,Status) - ; - Status=[], - C=Code - ). - -flora_body_literal(CanoniTerm,Code,Status) :- - get_flhashedvar_struct(CanoniTerm,C), + (get_flvar_struct(CanoniTerm,C); get_flhashedvar_struct(CanoniTerm,C); + get_flexclvar_struct(CanoniTerm,C)), !, ((PARSER_CONTEXT(parsing_facts);PARSER_CONTEXT(parsing_rulehead)) -> parsing_error(CanoniTerm,NO_PRED_VAR,Status) @@ -2857,12 +2858,12 @@ ; WSFlag = WITH_MODULE, - flora_term(Funct,N,Args,ALLOW_HASH,Code,Status) + flora_term(Funct,N,Args,ALLOW_HASH_EXCL,Code,Status) ). flora_body_wsliteral(CANOTERM(Funct,N,FL_PARENTHESIS,Args,_If,_Ip),_FloraModSpec,_WSFrom,WITH_MODULE,Code,Status) :- !, - flora_term(Funct,N,Args,ALLOW_HASH,Code,Status). + flora_term(Funct,N,Args,ALLOW_HASH_EXCL,Code,Status). flora_body_wsliteral(CANOTERM(Funct,N,FL_BRACKET,Args,_If,_Ip),_FloraModSpec,_WSFrom,WITH_MODULE,Code,Status) :- !, @@ -2908,7 +2909,7 @@ ). flora_body_wsliteral(CanoniTerm,_FloraModSpec,_WSFrom,WITH_MODULE,Code,Status) :- - get_flvar_struct(CanoniTerm,C), + (get_flvar_struct(CanoniTerm,C); get_flhashedvar_struct(CanoniTerm,C); get_flexclvar_struct(CanoniTerm,C)), !, ((PARSER_CONTEXT(parsing_facts);PARSER_CONTEXT(parsing_rulehead)) -> parsing_error(CanoniTerm,NO_PRED_VAR,Status) @@ -2917,15 +2918,10 @@ C=Code ). -flora_body_wsliteral(CanoniTerm,_FloraModSpec,_WSFrom,WITH_MODULE,Code,Status) :- - get_flhashedvar_struct(CanoniTerm,C), +flora_body_wsliteral(CanoniTerm,_FloraModSpec,_WSFrom,WITH_MODULE,_Code,Status) :- + get_flvar_struct(CanoniTerm,_C), !, - ((PARSER_CONTEXT(parsing_facts);PARSER_CONTEXT(parsing_rulehead)) -> - parsing_error(CanoniTerm,NO_PRED_VAR,Status) - ; - Status=[], - C=Code - ). + parsing_error(CanoniTerm,ERROR_VARPREFIX,Status). flora_body_wsliteral(CanoniTerm,_FloraModSpec,WS_FROM_DYNRULE,WITHOUT_MODULE,Code,Status) :- !, @@ -3096,7 +3092,7 @@ %% term flora_parse_body_literal_template(CanoniTerm,Code,Status) :- - flora_term_template(CanoniTerm,ALLOW_HASH,Code,Status), + flora_term_template(CanoniTerm,ALLOW_HASH_EXCL,Code,Status), !. flora_parse_body_literal_template(CanoniTerm,_Code,Status) :- @@ -3204,7 +3200,7 @@ ). flora_attmeth_template(CanoniTerm,Code,Status) :- - flora_term_template(CanoniTerm,ALLOW_HASH,C,Status), + flora_term_template(CanoniTerm,ALLOW_HASH_NOPREFIX,C,Status), (Status == [] -> ((is_flhashedterm_struct(C);is_flhashedobject_struct(C)) -> fltranspec_struct(C,Code) @@ -3261,17 +3257,19 @@ Status=S ). -flora_term_template(ObjectTerm,_HashFlag,Code,Status) :- +flora_term_template(ObjectTerm,HashFlag,Code,Status) :- %% primitive structures except named variables flobject_struct(ObjectTerm,Code), !, - (is_flvar_struct(Code), not is_anonymous_flvar_struct(Code) -> + ( is_flvar_struct(Code), not is_anonymous_flvar_struct(Code) -> parsing_error(ObjectTerm,ERROR_NAMEDVAR,Status) - ; - Status = [] + ; is_flvar_struct(Code), HashFlag==ALLOW_HASH_EXCL -> + parsing_error(ObjectTerm,ERROR_VARPREFIX,Status) + ; Status = [] ). -flora_term_template(ObjectTerm,ALLOW_HASH,Code,Status) :- +flora_term_template(ObjectTerm,HashFlag,Code,Status) :- + (HashFlag==ALLOW_HASH_NOPREFIX;HashFlag==ALLOW_HASH_EXCL), flhashedobject_struct(ObjectTerm,Code), !, (is_flhashedvar_struct(Code), not is_anonymous_flhashedvar_struct(Code) -> @@ -3280,6 +3278,15 @@ Status = [] ). +flora_term_template(ObjectTerm,ALLOW_HASH_EXCL,Code,Status) :- + flexclobject_struct(ObjectTerm,Code), + !, + (is_flexclvar_struct(Code), not is_anonymous_flexclvar_struct(Code) -> + parsing_error(ObjectTerm,ERROR_NAMEDVAR,Status) + ; + Status = [] + ). + flora_term_template(CanoniTerm,_HashFlag,_Code,Status) :- parsing_error(CanoniTerm,ERROR_TEMPLATE,Status). @@ -3457,7 +3464,7 @@ flora_term(Funct,N,Args,HashFlag,Code,Status) :- flhashedobject_struct(Funct,F), !, - ( HashFlag == ALLOW_HASH -> + ( (HashFlag==ALLOW_HASH_NOPREFIX;HashFlag==ALLOW_HASH_EXCL) -> flora_pathexplist(Args,AList,Status), (Status == [] -> flhashedterm_struct(F,N,AList,Code); true) ; @@ -3465,6 +3472,16 @@ ). flora_term(Funct,N,Args,HashFlag,Code,Status) :- + flexclobject_struct(Funct,F), + !, + ( HashFlag==ALLOW_HASH_EXCL -> + flora_pathexplist(Args,AList,Status), + (Status == [] -> flterm_struct(F,N,AList,Code); true) + ; + parsing_error(Funct,ERROR_EXCL_SYMBOL,Status) + ). + +flora_term(Funct,N,Args,HashFlag,Code,Status) :- change_atom_name_if_needed(Funct,Funct1), flora_pathexp(Funct1,HashFlag,F,S), ( S == [] -> @@ -3736,9 +3753,14 @@ !, parsing_error(ObjectTerm,ERROR_NEWOID,Status). -flora_pathexp(ObjectTerm,_HF,Code,[]) :- +flora_pathexp(ObjectTerm,HashFlag,Code,Status) :- flobject_struct(ObjectTerm,Code), - !. + !, + ( HashFlag==ALLOW_HASH_EXCL, is_flvar_struct(Code) -> + parsing_error(ObjectTerm,ERROR_VARPREFIX,Status) + ; + Status=[] + ). flora_pathexp(CANOBRACE(_L,_N,I),_HF,_Code,Status) :- !, @@ -3907,7 +3929,7 @@ fltranspec_struct(C,Code). flora_attmethspec(CanoniTerm,Code,Status) :- - flora_pathexp(CanoniTerm,ALLOW_HASH,C,Status), + flora_pathexp(CanoniTerm,ALLOW_HASH_NOPREFIX,C,Status), (Status == [] -> (is_flhashedterm_struct(C) -> fltranspec_struct(C,Code) @@ -4046,7 +4068,7 @@ flora_head_term(Funct,N,Args,HashFlag,Code,Status) :- flhashedobject_struct(Funct,F), !, - (HashFlag == ALLOW_HASH -> + ( (HashFlag==ALLOW_HASH_NOPREFIX;HashFlag==ALLOW_HASH_EXCL) -> flora_head_pathexplist(Args,AList,Status), (Status == [] -> flhashedterm_struct(F,N,AList,Code); true) ; @@ -4054,6 +4076,16 @@ ). flora_head_term(Funct,N,Args,HashFlag,Code,Status) :- + flexclobject_struct(Funct,F), + !, + ( HashFlag==ALLOW_HASH_EXCL -> + flora_head_pathexplist(Args,AList,Status), + (Status == [] -> flterm_struct(F,N,AList,Code); true) + ; + parsing_error(Funct,ERROR_EXCL_SYMBOL,Status) + ). + +flora_head_term(Funct,N,Args,HashFlag,Code,Status) :- flora_head_pathexp(Funct,HashFlag,F,S), ( S == [] -> flora_head_pathexplist(Args,AList,Status), @@ -4169,9 +4201,14 @@ !, flora_head_list(L,T,I,Code,Status). -flora_head_pathexp(ObjectTerm,_HF,Code,[]) :- +flora_head_pathexp(ObjectTerm,HashFlag,Code,Status) :- flobject_struct(ObjectTerm,Code), - !. + !, + ( HashFlag==ALLOW_HASH_EXCL, is_flvar_struct(Code) -> + parsing_error(ObjectTerm,ERROR_VARPREFIX,Status) + ; + Status=[] + ). %% ${...} - reification flora_head_pathexp(CANOTERM(Funct,N,FL_BRACE,Args,If,Ip),_HF,Code,Status) :- @@ -4293,7 +4330,7 @@ fltranspec_struct(C,Code). flora_head_attmethspec(CanoniTerm,Code,Status) :- - flora_head_pathexp(CanoniTerm,ALLOW_HASH,C,Status), + flora_head_pathexp(CanoniTerm,ALLOW_HASH_NOPREFIX,C,Status), (Status == [] -> (is_flhashedterm_struct(C) -> fltranspec_struct(C,Code) @@ -4630,7 +4667,7 @@ ( get_atom(Funct,F), flora_prlgdef(F,N) -> parsing_error(If,NO_PROLOG,Status) ; - flora_db_term(Mode,Funct,N,Args,ALLOW_HASH,Code,Status) + flora_db_term(Mode,Funct,N,Args,ALLOW_HASH_EXCL,Code,Status) ). flora_dblit(Mode,CANOTERM(Funct,N,FL_BRACKET,Args,_If,_Ip),Code,Status) :- @@ -4672,6 +4709,11 @@ not is_anonymous_flhashedvar_struct(Code), !. +flora_dblit(_Mode,CanoniTerm,Code,[]) :- + get_flexclvar_struct(CanoniTerm,Code), + not is_anonymous_flexclvar_struct(Code), + !. + flora_dblit(Mode,CanoniTerm,_Code,Status) :- !, ( Mode == FLINS -> @@ -4735,7 +4777,7 @@ ( get_atom(Funct,F), flora_nowsp(F,N) -> parsing_error(If,NO_WORKSPACE,Status) ; - flora_db_term(Mode,Funct,N,Args,ALLOW_HASH,Code,Status) + flora_db_term(Mode,Funct,N,Args,ALLOW_HASH_EXCL,Code,Status) ). flora_dbwslit(Mode,CANOTERM(Funct,N,FL_BRACKET,Args,_If,_Ip),Code,Status) :- @@ -4776,6 +4818,11 @@ not is_anonymous_flhashedvar_struct(Code), !. +flora_dbwslit(_Mode,CanoniTerm,Code,[]) :- + get_flexclvar_struct(CanoniTerm,Code), + not is_anonymous_flexclvar_struct(Code), + !. + /**** allow insert{Var@Mod} flora_dbwslit(_Mode,CanoniTerm,_Code,Status) :- get_flvar_struct(CanoniTerm,_V), @@ -4805,7 +4852,7 @@ flora_db_term(Mode,Funct,N,Args,HF,Code,Status) :- flhashedobject_struct(Funct,F), !, - (HF == ALLOW_HASH -> + ( (HF==ALLOW_HASH_NOPREFIX;HF==ALLOW_HASH_EXCL) -> flora_db_pathexplist(Mode,Args,AList,Status), (Status == [] -> flhashedterm_struct(F,N,AList,Code); true) ; @@ -4813,6 +4860,16 @@ ). flora_db_term(Mode,Funct,N,Args,HF,Code,Status) :- + flexclobject_struct(Funct,F), + !, + ( HF==ALLOW_HASH_EXCL -> + flora_db_pathexplist(Mode,Args,AList,Status), + (Status == [] -> flterm_struct(F,N,AList,Code); true) + ; + parsing_error(Funct,ERROR_EXCL_SYMBOL,Status) + ). + +flora_db_term(Mode,Funct,N,Args,HF,Code,Status) :- flora_db_pathexp(Mode,Funct,HF,F,S), ( S == [] -> flora_db_pathexplist(Mode,Args,AList,Status), @@ -4946,9 +5003,14 @@ %% Anonymous oid IS allowed in insert/delete -flora_db_pathexp(_Mode,ObjectTerm,_HF,Code,[]) :- +flora_db_pathexp(_Mode,ObjectTerm,HashFlag,Code,Status) :- flobject_struct(ObjectTerm,Code), - !. + !, + ( HashFlag==ALLOW_HASH_EXCL, is_flvar_struct(Code) -> + parsing_error(ObjectTerm,ERROR_VARPREFIX,Status) + ; + Status=[] + ). flora_db_pathexp(Mode,CanoniTerm,_HF,_Code,Status) :- ( Mode == FLINS -> @@ -5087,7 +5149,7 @@ fltranspec_struct(C,Code). flora_db_attmethspec(Mode,CanoniTerm,Code,Status) :- - flora_db_pathexp(Mode,CanoniTerm,ALLOW_HASH,C,Status), + flora_db_pathexp(Mode,CanoniTerm,ALLOW_HASH_NOPREFIX,C,Status), (Status == [] -> (is_flhashedterm_struct(C) -> fltranspec_struct(C,Code) @@ -5272,6 +5334,12 @@ ; Status=[] ) + ; get_flexclvar_struct(CanoniTerm,Code) -> + ( is_anonymous_flexclvar_struct(Code) -> + parsing_error(I,ERROR_HDLITERAL,Status) + ; + Status=[] + ) ; flora_head_literal(CanoniTerm,Code,Status) ). Index: flrcomposer.P =================================================================== RCS file: /cvsroot/flora/flora2/flrcomposer.P,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- flrcomposer.P 2 Feb 2005 12:11:09 -0000 1.5 +++ flrcomposer.P 21 Mar 2005 06:55:00 -0000 1.6 @@ -142,6 +142,8 @@ is_sole_operand(HASHED_NUMBER(_,_)) :- !. is_sole_operand(HASHED_SYMBOL_TOKEN(_,_)) :- !. +is_sole_operand(EXCL_VARIABLE(_,_)) :- !. + is_sole_operand(IDENTIFIER(I,_)) :- \+ flora_opdef(_,_,I), !. is_sole_operand(QUOTED_ATOM(QA,_)) :- \+ flora_opdef(_,_,QA), !. is_sole_operand(SYMBOL_TOKEN(ST,_)) :- \+ flora_opdef(_,_,ST), !. Index: flrdependency.P =================================================================== RCS file: /cvsroot/flora/flora2/flrdependency.P,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- flrdependency.P 2 Feb 2005 12:11:09 -0000 1.20 +++ flrdependency.P 21 Mar 2005 06:55:00 -0000 1.21 @@ -486,6 +486,8 @@ true ; HC=FL_HASHED(Var), var(Var) -> Wrap=WRAP_HILOG + ; HC=FL_EXCL(Var), var(Var) -> + Wrap=WRAP_TABLED_HILOG ; ( functor(HC,DB,3), dboperation(DB,3) -> HC =.. [DB,WS,DBList,Cond], Index: flrlexer.P =================================================================== RCS file: /cvsroot/flora/flora2/flrlexer.P,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- flrlexer.P 2 Feb 2005 12:11:09 -0000 1.9 +++ flrlexer.P 21 Mar 2005 06:55:01 -0000 1.10 @@ -171,6 +171,7 @@ flora_hashed_identifier_struct(+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) flora_variable_struct(+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) flora_hashed_variable_struct(+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) + flora_excl_variable_struct(+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) flora_number_struct(+Num,+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) flora_hashed_number_struct(+Num,+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) flora_quoted_atom_struct(+AtomStr,+TextStr,+LN1,+CN1,+LN2,+CN2,-Token) @@ -199,6 +200,10 @@ text_info(LN1,CN1,LN2,CN2,TextStr,Text), atom_codes(A,TextStr). +flora_excl_variable_struct(TextStr,LN1,CN1,LN2,CN2,EXCL_VARIABLE(A,Text)) :- + text_info(LN1,CN1,LN2,CN2,TextStr,Text), + atom_codes(A,TextStr). + flora_hashed_variable_struct(TextStr,LN1,CN1,LN2,CN2,HASHED_VARIABLE(A,Text)) :- text_info(LN1,CN1,LN2,CN2,TextStr,Text), atom_codes(A,TextStr). @@ -271,6 +276,9 @@ flora_token_text(VARIABLE(_A,Text),TextStr,BLN,BCN,ELN,ECN) :- text_info(BLN,BCN,ELN,ECN,TextStr,Text). +flora_token_text(EXCL_VARIABLE(_A,Text),[CH_EXCLAMATION|TextStr],BLN,BCN,ELN,ECN) :- + text_info(BLN,BCN,ELN,ECN,TextStr,Text). + flora_token_text(HASHED_VARIABLE(_A,Text),[CH_HASH|TextStr],BLN,BCN,ELN,ECN) :- text_info(BLN,BCN,ELN,ECN,TextStr,Text). @@ -430,6 +438,9 @@ ; Char == CH_HASH -> read_hashed_token(Char,LineNo,CharNo,NextLN,NextCN,TokenList,Status) + ; Char == CH_EXCLAMATION -> + read_excl_token(Char,LineNo,CharNo,NextLN,NextCN,TokenList,Status) + ; Char >= CH_a, Char =< CH_z -> read_identifier(Char,LineNo,CharNo,NextLN,NextCN,TokenList,Status) @@ -464,6 +475,27 @@ ). /**************************************************************************** + read_excl_token(+Char,+LineNo,+CharNo,+NextLN,+NextCN,-TokenList,-Status) + parses variables starting from Char which is !. +****************************************************************************/ +read_excl_token(C1,LN1,CN1,LN,CN,TokenList,Status) :- + get_char(LN,CN,Ch,NextLN,NextCN), + ( Ch >= CH_A, Ch =< CH_Z -> + read_excl_named_variable(Ch,LN1,CN1,LN,CN,NextLN,NextCN,TokenList,Status) + ; Ch == CH_UNDERSCORE -> + read_excl_underscore_variable(Ch,LN1,CN1,LN,CN,NextLN,NextCN,TokenList,Status) + ; Ch == CH_EXCLAMATION -> + flora_symbol_token_struct([Ch,Ch],LN1,CN1,LN,CN,Tk), + get_char(NextLN,NextCN,C2,NLN,NCN), + read_tokens(C2,NextLN,NextCN,NLN,NCN,Tokens,Status), + TokenList=[Tk|Tokens] + ; + flora_symbol_token_struct([C1],LN1,CN1,LN1,CN1,Tk), + read_tokens(Ch,LN,CN,NextLN,NextCN,Tokens,Status), + TokenList=[Tk|Tokens] + ). + +/**************************************************************************** read_hashed_tokens(+Char,+LineNo,+CharNo,+NextLN,+NextCN,-TokenList,-Status) parses tokens starting from Char which is #. ****************************************************************************/ @@ -622,6 +654,17 @@ read_tokens(NextCh,NLN,NCN,NNLN,NNCN,Tokens,Status). /**************************************************************************** + read_excl_named_variable(+Char,+LNof#,+CNof#,+LN,+CN,+NextLN,+NextCN,-TokenList,-Status) + reads a variable name following a ! +****************************************************************************/ +read_excl_named_variable(C2,LN1,CN1,LN2,CN2,LN,CN,TokenList,Status) :- + read_name(C2,LN2,CN2,LN,CN,Chars,LN3,CN3,NextCh,NLN,NCN,NNLN,NNCN), + flora_excl_variable_struct(Chars,LN1,CN1,LN3,CN3,Tk), + TokenList=[Tk|Tokens], + !, + read_tokens(NextCh,NLN,NCN,NNLN,NNCN,Tokens,Status). + +/**************************************************************************** read_hashed_variable(+Char,+LNof#,+CNof#,+LN,+CN,+NextLN,+NextCN,-TokenList,-Status) reads a variable name following a # ****************************************************************************/ @@ -721,6 +764,38 @@ /**************************************************************************** + read_excl_underscore_variable(+Char,+LNof#,+CNof#,+LN,+CN,+NextLN,+NextCN,-TokenList,-Status) + reads an underscore variable name following a ! +****************************************************************************/ +read_excl_underscore_variable(C2,LN1,CN1,LN2,CN2,LN,CN,TokenList,Status) :- + get_char(LN,CN,Ch,NextLN,NextCN), + ( Ch >= CH_a, Ch =< CH_z -> + read_name(Ch,LN,CN,NextLN,NextCN,Chars,LN3,CN3,NCh,NLN,NCN,NNLN,NNCN) + + ; Ch >= CH_A, Ch =< CH_Z -> + read_name(Ch,LN,CN,NextLN,NextCN,Chars,LN3,CN3,NCh,NLN,NCN,NNLN,NNCN) + + ; Ch >= CH_0, Ch =< CH_9 -> + read_name(Ch,LN,CN,NextLN,NextCN,Chars,LN3,CN3,NCh,NLN,NCN,NNLN,NNCN) + + ; Ch == CH_UNDERSCORE -> + read_name(Ch,LN,CN,NextLN,NextCN,Chars,LN3,CN3,NCh,NLN,NCN,NNLN,NNCN) + ; + Chars=[], + LN3=LN2, + CN3=CN2, + NCh=Ch, + NLN=LN, + NCN=CN, + NNLN=NextLN, + NNCN=NextCN + ), + flora_excl_variable_struct([C2|Chars],LN1,CN1,LN3,CN3,Tk), + TokenList=[Tk|Tokens], + !, + read_tokens(NCh,NLN,NCN,NNLN,NNCN,Tokens,Status). + +/**************************************************************************** read_hashed_underscore_variable(+Char,+LNof#,+CNof#,+LN,+CN,+NextLN,+NextCN,-TokenList,-Status) reads an underscore variable name following a # ****************************************************************************/ @@ -752,6 +827,7 @@ !, read_tokens(NCh,NLN,NCN,NNLN,NNCN,Tokens,Status). + /**************************************************************************** read_special(+Ch,+LineNo,+CharNo,+NextLN,+NextCN,-Tokens,-Status) handles tokens made of special symbols. @@ -789,18 +865,6 @@ read_comment_line(Ch,LN,CN,NLN,NCN,LN1,CN1,TxChs,LN2,CN2,Tokens,Status). */ -read_special(CH_EXCLAMATION,LN1,CN1,LN,CN,[Tk|Tokens],Status) :- - !, - get_char(LN,CN,C1,NextLN,NextCN), - ( C1 == CH_EXCLAMATION -> - flora_symbol_token_struct([C1,C1],LN1,CN1,LN,CN,Tk), - get_char(NextLN,NextCN,C2,NLN,NCN), - read_tokens(C2,NextLN,NextCN,NLN,NCN,Tokens,Status) - ; - flora_symbol_token_struct([CH_EXCLAMATION],LN1,CN1,LN1,CN1,Tk), - read_tokens(C1,LN,CN,NextLN,NextCN,Tokens,Status) - ). - read_special(CH_DOT,LN1,CN1,LN,CN,Tokens,Status) :- !, get_char(LN,CN,C1,NextLN,NextCN), |
|
From: Chang Z. <ch...@us...> - 2005-03-21 06:55:09
|
Update of /cvsroot/flora/flora2/flrincludes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4343/flrincludes Modified Files: flora_errors.flh flora_terms.flh Log Message: introduce variables prefixed with ! for tabled predicates Index: flora_terms.flh =================================================================== RCS file: /cvsroot/flora/flora2/flrincludes/flora_terms.flh,v retrieving revision 1.50 retrieving revision 1.51 diff -u -d -r1.50 -r1.51 --- flora_terms.flh 2 Feb 2005 12:11:11 -0000 1.50 +++ flora_terms.flh 21 Mar 2005 06:55:00 -0000 1.51 @@ -54,6 +54,7 @@ #define HASHED_IDENTIFIER hashed_identifier #define VARIABLE variable #define HASHED_VARIABLE hashed_variable +#define EXCL_VARIABLE excl_variable #define NUMBER number #define HASHED_NUMBER hashed_number #define QUOTED_ATOM quoted_atom @@ -388,6 +389,7 @@ #define FLHASHEDSTRING flhashedstring #define FLVAR flvar #define FLHASHEDVAR flhashedvar +#define FLEXCLVAR flexclvar #define FLTOKEN fltoken #define FLTERM flterm #define FLHASHEDTERM flhashedterm @@ -515,6 +517,7 @@ #define PRHASHEDNUMBER prhashednumber #define PRVARIABLE prvariable #define PRHASHEDVARIABLE prhashedvariable +#define PREXCLVARIABLE prexclvariable #define PRSTRING prstring #define PRLIST prlist #define PRTERM prterm @@ -884,6 +887,7 @@ #define FLORA_IGNORE_UNDEFCHECK ignore_undefcheck #define FL_HASHED FLORA_SYMBOL('hashed') +#define FL_EXCL FLORA_SYMBOL('excl') #define FL_TABLED FLORA_SYMBOL('tabled') #define FL_NOTTABLED FLORA_SYMBOL('nottabled') #define FL_TERM FLORA_SYMBOL('term') Index: flora_errors.flh =================================================================== RCS file: /cvsroot/flora/flora2/flrincludes/flora_errors.flh,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- flora_errors.flh 2 Feb 2005 12:11:11 -0000 1.30 +++ flora_errors.flh 21 Mar 2005 06:55:00 -0000 1.31 @@ -188,7 +188,9 @@ #define ERROR_EXPORT_MODULE 'export to invalid module' #define ERROR_EXPORT_ATOM_ATTR 'variable occurs where term is expected' -#define ERROR_HASHED_SYMBOL 'unexpected hashed symbol' +#define ERROR_HASHED_SYMBOL 'unexpected symbol with #' +#define ERROR_EXCL_SYMBOL 'unexpected symbol with !' +#define ERROR_VARPREFIX 'missing ! or # before variable' /************************************** warnings reported by Flora Compiler |
|
From: Chang Z. <ch...@us...> - 2005-03-21 06:55:09
|
Update of /cvsroot/flora/flora2/syslib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4343/syslib Modified Files: flrbtdbop.P flrcanon.P flrdbop.P flrdecode.P flrdynmod.P flrmetaops.P flrstorageutils.P Log Message: introduce variables prefixed with ! for tabled predicates Index: flrstorageutils.P =================================================================== RCS file: /cvsroot/flora/flora2/syslib/flrstorageutils.P,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- flrstorageutils.P 2 Feb 2005 12:11:12 -0000 1.6 +++ flrstorageutils.P 21 Mar 2005 06:55:00 -0000 1.7 @@ -40,19 +40,22 @@ flora_module_name_error/1, flora_fdb_storage_name/2, flora_decode_module_name/2 - %%flora_module_predicate/4 from flrwrapper. -:- import get_canonical_form/2 from flrcanon. +:- import + get_canonical_form/2, + flora_is_tabled_predicate/1, + flora_is_nontabled_predicate/1 + from flrcanon. :- import flora_add_last/3 from flrtrim. :- import flora_decode_goal_as_atom/2 from flrdecode. -%%:- import flora_abort/0, flora_abort/1, -:- import flora_abort/1, +:- import + flora_abort/1, flora_load_system_module_internal/1 - from flrutils. + from flrutils. :- import FLSYSDBUPDATE/2, @@ -164,6 +167,7 @@ flora_construct_delete_predicate(ThisModuleName,ModuleName,P) :- var(P), + !, flora_module_registry(ModuleName), flora_fdb_storage_name(ModuleName,StorageName), flora_check_export_registry_internal(ThisModuleName,ModuleName,EP,FLEXPORT_UPDATABLE), @@ -175,11 +179,21 @@ EP = P ). +flora_construct_delete_predicate(_ThisModuleName,_ModuleName,_P). + /***************************************************************************** flora_storage_convertlist(+ThisModule,+List,-CallList,-FactList) *****************************************************************************/ flora_storage_convertlist(_ThisModule,[],[],[]) :- !. +flora_storage_convertlist(ThisModule,[Var|Fs], + [flora_construct_delete_predicate(ThisModule,_ModuleName,Var), flora_storage_check_deletepredicate(Var,UpdateStruct)|CL], + [UpdateStruct|FL]) :- + var(Var), + !, + flora_storage_convertlist(ThisModule,Fs,CL,FL). + + flora_storage_convertlist(ThisModule,[FLLIBMODOBJ(F,A,MN,C,O)|Fs],CL,FL) :- !, flora_storage_convertlist(ThisModule,Fs,RCL,FL), @@ -191,6 +205,13 @@ ). flora_storage_convertlist(ThisModule,[FLLIBMODLIT(FL_LIBMOD,Var,Mod,_Caller)|Fs], + [flora_construct_delete_predicate(ThisModule,Mod,Var),flora_storage_check_deletepredicate(Var,UpdateStruct)|CL], + [UpdateStruct|FL]) :- + var(Var), + !, + flora_storage_convertlist(ThisModule,Fs,CL,FL). + +flora_storage_convertlist(ThisModule,[FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Var),Mod,_Caller)|Fs], [flora_construct_delete_predicate(ThisModule,ModuleName,Var), get_canonical_form(Var,FLCANON(_,_,_,_,FL_TABLED)),flora_storage_check_deletepredicate(Var,UpdateStruct)|CL], [UpdateStruct|FL]) :- var(Var), @@ -214,13 +235,9 @@ ), flora_storage_convertlist(ThisModule,Fs,CL,FL). -flora_storage_convertlist(ThisModule,[FLLIBMODLIT(FL_LIBMOD,','(First,Rest),Mod,Caller)|Fs],CL,FL) :- - !, - flora_storage_convertlist(ThisModule,[FLLIBMODLIT(FL_LIBMOD,First,Mod,Caller),FLLIBMODLIT(FL_LIBMOD,Rest,Mod,Caller)|Fs],CL,FL). - -flora_storage_convertlist(ThisModule,[FLLIBMODLIT(FL_LIBMOD,FL_HASHED(','(First,Rest),Mod,Caller))|Fs],CL,FL) :- +flora_storage_convertlist(ThisModule,[','(First,Rest)|Fs],CL,FL) :- !, - flora_storage_convertlist(ThisModule,[FLLIBMODLIT(FL_LIBMOD,FL_HASHED(First),Mod,Caller),FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Rest),Mod,Caller)|Fs],CL,FL). + flora_storage_convertlist(ThisModule,[First,Rest|Fs],CL,FL). flora_storage_convertlist(ThisModule,[FLLIBMODLIT(FL_LIBMOD,FLLIBMODOBJ(F,A,MN,C,O),_Mod,_Caller)|Fs],CL,FL) :- !, @@ -242,6 +259,95 @@ CL=RCL ). +flora_storage_convertlist(ThisModule,[FLLIBMODLIT(FL_LIBMOD,FL_EXCL(FLLIBMODOBJ(F,A,MN,C,O)),_Mod,_Caller)|Fs],CL,FL) :- + !, + flora_storage_convertlist(ThisModule,Fs,RCL,FL), + FLLIBMODOBJ(F,A,MN,C,O), + ( var(O) -> + append(RCL, [FLLIBMODOBJ(F,A,MN,C,O)], CL) + ; + CL=RCL + ). + +flora_storage_convertlist(ThisModule,[FLLIBMODLIT(FL_LIBMOD,','(FLLIBMODOBJ(F,A,MN,C,O),Rest),_Mod,_Caller)|Fs],CL,FL) :- + !, + flora_storage_convertlist(ThisModule,[FLLIBMODOBJ(F,A,MN,C,O),Rest|Fs],CL,FL). + +flora_storage_convertlist(ThisModule,[FLLIBMODLIT(FL_LIBMOD,FL_HASHED(','(FLLIBMODOBJ(F,A,MN,C,O),Rest)),_Mod,_Caller)|Fs],CL,FL) :- + !, + flora_storage_convertlist(ThisModule,[FLLIBMODOBJ(F,A,MN,C,O),Rest|Fs],CL,FL). + +flora_storage_convertlist(ThisModule,[FLLIBMODLIT(FL_LIBMOD,FL_EXCL(','(FLLIBMODOBJ(F,A,MN,C,O),Rest)),_Mod,_Caller)|Fs],CL,FL) :- + !, + flora_storage_convertlist(ThisModule,[FLLIBMODOBJ(F,A,MN,C,O),Rest|Fs],CL,FL). + +flora_storage_convertlist(ThisModule,[FLLIBMODLIT(FL_LIBMOD,Pred,Mod,Caller)|Fs],CL,FL) :- + %% X@M where X is bound + ( (atom(Pred);Pred=..[WRAP_HILOG|_]) -> + flora_abort('! or # expected') + ; Pred = ','(First,Rest) -> + flora_storage_convertlist(ThisModule,[FLLIBMODLIT(FL_LIBMOD,First,Mod,Caller),FLLIBMODLIT(FL_LIBMOD,Rest,Mod,Caller)|Fs],CL,FL) + ; + get_canonical_form(FLLIBMODLIT(FL_LIBMOD,Pred,Mod,Caller),FLCANON(_,_,_,NP,_)), + CL = [flora_check_deletepredicate(NP,UpdateStruct)|RCL], + FL = [UpdateStruct|RFL], + flora_storage_convertlist(ThisModule,Fs,RCL,RFL) + ). + +flora_storage_convertlist(ThisModule,[FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Pred),Mod,Caller)|Fs],[flora_check_deletepredicate(NP,UpdateStruct)|CL],[UpdateStruct|FL]) :- + %% #X or #X@M where X is bound + ( Mod == FL_INVALIDMODULE -> + ( flora_is_nontabled_predicate(Pred) -> + true + ; + flora_abort('non-tabled predicate expected') + ) + ; + ( (atom(Pred);Pred=..[WRAP_HILOG|_];flora_is_nontabled_predicate(Pred)) -> + true + ; + flora_abort('term or non-tabled predicate expected') + ) + ), + ( Pred = ','(First,Rest) -> + %% Rest is the conjunction of 1 to more fllibmodobj + get_canonical_form(First,FLCANON(_,_,NewMod,NP,_)), + flora_storage_convertlist(ThisModule,Rest,TCL,_TFL), + append(TCL,RCL,CL) + ; + get_canonical_form(FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Pred),Mod,Caller),FLCANON(_,_,NewMod,NP,_)), + CL=RCL + ), + + flora_storage_convertlist(ThisModule,Fs,RCL,FL). + +flora_storage_convertlist(ThisModule,[FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Pred),Mod,Caller)|Fs],[flora_check_deletepredicate(NP,UpdateStruct)|CL],[UpdateStruct|FL]) :- + %% !X or !X@M where X is bound + ( Mod == FL_INVALIDMODULE -> + ( flora_is_tabled_predicate(Pred) -> + true + ; + flora_abort('tabled predicate expected') + ) + ; + ( (atom(Pred);Pred=..[WRAP_HILOG|_];flora_is_tabled_predicate(Pred)) -> + true + ; + flora_abort('term or tabled predicate expected') + ) + ), + ( Pred = ','(First,Rest) -> + %% Rest is the conjunction of 1 to more fllibmodobj + get_canonical_form(First,FLCANON(_,_,NewMod,NP,_)), + flora_storage_convertlist(ThisModule,Rest,TCL,_TFL), + append(TCL,RCL,CL) + ; + get_canonical_form(FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Pred),Mod,Caller),FLCANON(_,_,NewMod,NP,_)), + CL=RCL + ), + + flora_storage_convertlist(ThisModule,Fs,RCL,FL). + flora_storage_convertlist(ThisModule,[FLLIBMODLIT(Wrap,Args,Mod,Caller)|Fs], [get_canonical_form(FLLIBMODLIT(Wrap,Args,Mod,Caller),FLCANON(_,_,Module,P,_)),flora_check_export_registry_internal(ThisModule,Module,P,FLEXPORT_UPDATABLE),flora_storage_check_deletepredicate(P,UpdateStruct)|CL], [UpdateStruct|FL]) :- Index: flrdecode.P =================================================================== RCS file: /cvsroot/flora/flora2/syslib/flrdecode.P,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- flrdecode.P 2 Feb 2005 12:11:12 -0000 1.31 +++ flrdecode.P 21 Mar 2005 06:55:00 -0000 1.32 @@ -649,6 +649,10 @@ !, decode_literal_internal(Term,Code,Level,Depth). +decode_literal_internal(FL_EXCL(Term),Code,Level,Depth) :- + !, + decode_literal_internal(Term,Code,Level,Depth). + decode_literal_internal(FLLIBNEWMODULE(_ThisModule,NewModuleName), [ReifyStart,FL_NEWMODULE,'{',NewModuleName,'}',ReifyEnd], Level,_Depth) :- @@ -738,7 +742,8 @@ workspace_code(Module,ModuleCode), Code = ['#', TermCode, ModuleCode] ; - decode_hilog_call(Basename,ArgList,Module,Code,0,Depth1) + decode_hilog_call(Basename,ArgList,Module,TCode,0,Depth1), + (TCode = ['${'|Rest] -> Code = ['${','#'|Rest]; Code = ['#',TCode]) ), decode_literal_internal(ResultObj,ResCode,1,Depth1). Index: flrdbop.P =================================================================== RCS file: /cvsroot/flora/flora2/syslib/flrdbop.P,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- flrdbop.P 2 Feb 2005 12:11:12 -0000 1.26 +++ flrdbop.P 21 Mar 2005 06:54:59 -0000 1.27 @@ -67,7 +67,9 @@ :- import get_canonical_form/2, - convert_to_head_literal/2 + convert_to_head_literal/2, + flora_is_tabled_predicate/1, + flora_is_nontabled_predicate/1 from flrcanon. :- import flora_refresh_tables/1 from flrtables. @@ -124,39 +126,154 @@ !, flora_abort('Uninstantiated argument in insert{...}'). +flora_storage_insertfacts(_ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Var),_ModuleName1,_Caller)|_T]) :- + var(Var), + !, + flora_abort('Uninstantiated argument in insert{...}'). + flora_storage_insertfacts(_ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Var),_ModuleName1,_Caller)|_T]) :- var(Var), !, flora_abort('Uninstantiated argument in insert{...}'). -flora_storage_insertfacts(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,(First,Rest),ModuleName1,Caller)|T]) :- +flora_storage_insertfacts(ThisModuleName,[(First,Rest)|T]) :- !, ( Rest = FLLIBMODOBJ(_F,_A,_MN,_C,O) -> Rest, ( var(O) -> flora_abort(['Uninstantiated predicate in an argument positition in insert{...}']) ; - flora_storage_insertfacts(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,First,ModuleName1,Caller)]) + flora_storage_insertfacts(ThisModuleName,[First]) + ) + ; Rest = ','(FLLIBMODOBJ(F,A,MN,C,O),R1) -> + FLLIBMODOBJ(F,A,MN,C,O), + ( var(O) -> + flora_abort(['Uninstantiated predicate in an argument positition in insert{...}']) + ; + flora_storage_insertfacts(ThisModuleName,[','(First,R1)]) ) ; %% For cases such as %% X = ','(a,b), insert{X} - flora_storage_insertfacts(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,First,ModuleName1,Caller)]), - flora_storage_insertfacts(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,Rest,ModuleName1,Caller)]) + flora_storage_insertfacts(ThisModuleName,[First,Rest]) ), flora_storage_insertfacts(ThisModuleName,T). -%% insert{#X} where X is bound flora_storage_insertfacts(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Arg),Module,_Caller)|T]) :- Module==FL_INVALIDMODULE, !, - flora_storage_insertfacts(ThisModuleName,[Arg|T]). + ( flora_is_nontabled_predicate(Arg) -> + ( Arg = ','(First,Rest) -> + %% Rest is conjunction of 0 to more fllibmobobj + flora_storage_insertfacts(ThisModuleName,[Rest,First|T]) + ; + flora_storage_insertfacts(ThisModuleName,[Arg|T]) + ) + ; + flora_abort(['non-tabled predicate expected']) + ). -%% insert{X} where X is bound -flora_storage_insertfacts(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,Arg,Module,_Caller)|T]) :- +flora_storage_insertfacts(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Arg),Module,Caller)|T]) :- + %% #X@M + !, + ( (atom(Arg); Arg =.. [WRAP_HILOG|_]) -> + %% a term + P2H_CONVERSION(Module,ModuleName1), + flora_storage_check_module_name(ModuleName1), + (get_canonical_form(FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Arg),Module,Caller), FLCANON(_,_,_,P,_)) -> true + ; + flora_decode_goal_as_atom(Arg,AtomArg), + flora_abort(['A non-fact found in insert{...}, ', AtomArg]) + ), + convert_to_head_literal(P,HeadP), + flora_fdb_storage_name(ModuleName1,StorageName), + flora_internal_db_insert(StorageName,HeadP), + flora_storage_insertfacts(ThisModuleName,T) + + ; flora_is_nontabled_predicate(Arg) -> + %% a non-tabled predicate + ( Arg = ','(First,Rest) -> + %% Rest is conjunction of 0 to more fllibmobobj + flora_storage_insertfacts(ThisModuleName,[Rest,First|T]) + ; + flora_storage_insertfacts(ThisModuleName,[Arg|T]) + ) + ; + flora_abort(['term or non-tabled predicate expected']) + ). + +flora_storage_insertfacts(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Arg),Module,_Caller)|T]) :- Module==FL_INVALIDMODULE, !, - flora_storage_insertfacts(ThisModuleName,[Arg|T]). + ( flora_is_tabled_predicate(Arg) -> + ( Arg = ','(First,Rest) -> + %% Rest is conjunction of 0 to more fllibmobobj + flora_storage_insertfacts(ThisModuleName,[Rest,First|T]) + ; + flora_storage_insertfacts(ThisModuleName,[Arg|T]) + ) + ; + flora_abort(['tabled predicate expected']) + ). + +flora_storage_insertfacts(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Arg),Module,Caller)|T]) :- + %% !X@M + !, + ( (atom(Arg); Arg =.. [WRAP_HILOG|_]) -> + %% a term + P2H_CONVERSION(Module,ModuleName1), + flora_storage_check_module_name(ModuleName1), + (get_canonical_form(FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Arg),Module,Caller), FLCANON(_,_,_,P,_)) -> true + ; + flora_decode_goal_as_atom(Arg,AtomArg), + flora_abort(['A non-fact found in insert{...}, ', AtomArg]) + ), + convert_to_head_literal(P,HeadP), + flora_fdb_storage_name(ModuleName1,StorageName), + flora_internal_db_insert(StorageName,HeadP), + flora_storage_insertfacts(ThisModuleName,T) + + ; flora_is_tabled_predicate(Arg) -> + %% a tabled predicate + ( Arg = ','(First,Rest) -> + %% Rest is conjunction of 0 to more fllibmobobj + flora_storage_insertfacts(ThisModuleName,[Rest,First|T]) + ; + flora_storage_insertfacts(ThisModuleName,[Arg|T]) + ) + ; + flora_abort(['term or tabled predicate expected']) + ). + +flora_storage_insertfacts(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,Arg,Module,Caller)|T]) :- + %% X@M + !, + ( (atom(Arg); Arg =.. [WRAP_HILOG|_]) -> + flora_abort('! or # expected') + + ; Arg = ','(First,Rest) -> + ( Rest = FLLIBMODOBJ(_F,_A,_MN,_C,O) -> + Rest, + ( var(O) -> + flora_abort(['Uninstantiated predicate in an argument positition in insert{...}']) + ; + flora_storage_insertfacts(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,First,Module,Caller)]) + ) + ; Rest = ','(FLLIBMODOBJ(F,A,MN,C,O),R1) -> + FLLIBMODOBJ(F,A,MN,C,O), + ( var(O) -> + flora_abort(['Uninstantiated predicate in an argument positition in insert{...}']) + ; + flora_storage_insertfacts(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,','(First,R1),Module,Caller)]) + ) + ; + flora_storage_insertfacts(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,First,ModuleName1,Caller)]), + flora_storage_insertfacts(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,Rest,ModuleName1,Caller)]) + ) + ; + flora_storage_insertfacts(ThisModuleName,[Arg]) + ), + flora_storage_insertfacts(ThisModuleName,T). flora_storage_insertfacts(ThisModuleName,[FLLIBMODLIT(F,Args,ModuleName1,Caller)|T]) :- !, @@ -264,6 +381,18 @@ The semantics is such that all the literals in "List" must be base facts in the storage to be deleted. *****************************************************************************/ +FLLIBDELETE(ThisModuleName,[Var],true) :- + var(Var), + %% delete any predicate in any module + !, + flora_module_registry(ModuleName), + flora_fdb_storage_name(ModuleName,StorageName), + flora_check_export_registry_internal(ThisModuleName,ModuleName,Var,FLEXPORT_UPDATABLE), + flora_db_find_base(StorageName,Var), + flora_add_last(Var,NP,ThisModuleName), + !, + flora_internal_db_delete(StorageName,NP). + FLLIBDELETE(ThisModuleName,[FLSYSDBUPDATE(P,StorageName,Module)],true) :- !, flora_storage_check_existence(Module), @@ -271,7 +400,25 @@ flora_db_find_base(StorageName,P), flora_internal_db_delete(StorageName,P). -FLLIBDELETE(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,Var,Mod,_Caller)],true) :- +FLLIBDELETE(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,Var,ModuleName,_Caller)],true) :- + var(Var), + %% delete any predicate in module ModuleName + !, + flora_module_registry(ModuleName), + flora_fdb_storage_name(ModuleName,StorageName), + flora_check_export_registry_internal(ThisModuleName,ModuleName,P,FLEXPORT_UPDATABLE), + ( var(P) -> + flora_db_find_base(StorageName,P), + flora_add_last(P,NP,ThisModuleName) + ; + flora_db_find_base(StorageName,P), + NP = P + ), + get_canonical_form(NP,FLCANON(_,_,_,Var,_)), + !, + flora_internal_db_delete(StorageName,NP). + +FLLIBDELETE(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Var),Mod,_Caller)],true) :- var(Var), %% delete any tabled predicate in any module !, @@ -294,6 +441,35 @@ !, flora_internal_db_delete(StorageName,NP). +FLLIBDELETE(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Pred),Mod,Caller)],true) :- + !, + %% delete{!X} or delete{!X@M} where X is bound + ( Mod == FL_INVALIDMODULE -> + ( flora_is_tabled_predicate(Pred) -> + true + ; + flora_abort('tabled predicate expected') + ) + ; + ( (atom(Pred);Pred=..[WRAP_HILOG|_];flora_is_tabled_predicate(Pred)) -> + true + ; + flora_abort('term or tabled predicate expected') + ) + ), + ( Pred = ','(First,Rest) -> + %% Rest is the conjunction of 1 to more fllibmodobj + get_canonical_form(First,FLCANON(_,_,NewMod,NP,_)) + ; + get_canonical_form(FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Pred),Mod,Caller),FLCANON(_,_,NewMod,NP,_)) + ), + flora_storage_check_existence(NewMod), + flora_check_export_registry(ThisModuleName,NewMod,NP,FLEXPORT_UPDATABLE), + flora_fdb_storage_name(NewMod,StorageName), + flora_db_find_base(StorageName,NP), + ( nonvar(Rest) -> Rest ; true), + flora_internal_db_delete(StorageName,NP). + FLLIBDELETE(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Var),Mod,_Caller)],true) :- var(Var), %% delete any non-tabled predicate in any module @@ -317,6 +493,35 @@ !, flora_internal_db_delete(StorageName,NP). +FLLIBDELETE(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Pred),Mod,Caller)],true) :- + !, + %% delete{#X} or delete{#X@M} where X is bound + ( Mod == FL_INVALIDMODULE -> + ( flora_is_nontabled_predicate(Pred) -> + true + ; + flora_abort('non-tabled predicate expected') + ) + ; + ( (atom(Pred);Pred=..[WRAP_HILOG|_];flora_is_nontabled_predicate(Pred)) -> + true + ; + flora_abort('term or non-tabled predicate expected') + ) + ), + ( Pred = ','(First,Rest) -> + %% Rest is the conjunction of 1 to more fllibmodobj + get_canonical_form(First,FLCANON(_,_,NewMod,NP,_)) + ; + get_canonical_form(FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Pred),Mod,Caller),FLCANON(_,_,NewMod,NP,_)) + ), + flora_storage_check_existence(NewMod), + flora_check_export_registry(ThisModuleName,NewMod,NP,FLEXPORT_UPDATABLE), + flora_fdb_storage_name(NewMod,StorageName), + flora_db_find_base(StorageName,NP), + ( nonvar(Rest) -> Rest ; true), + flora_internal_db_delete(StorageName,NP). + FLLIBDELETE(ThisModuleName,List,Condition) :- flora_storage_convertlist(ThisModuleName,List,CallList,FactList), flora_list2conjunct([Condition|CallList],Goal), @@ -366,13 +571,27 @@ The semantics is such that all the literals in "List" must be base facts in the storage to be deleted. This call always succeeds. *****************************************************************************/ +FLLIBDELETEALL(ThisModuleName,[Var],true) :- + var(Var), + %% delete any predicate in any module + !, + findall(FLSYSDBUPDATE(Var,Storage),(flora_construct_delete_predicate(ThisModuleName,ModuleName,Var),flora_fdb_storage_name(ModuleName,Storage)),FsList), + flora_storage_deletelist(ThisModuleName,FsList). + FLLIBDELETEALL(ThisModuleName,[FLSYSDBUPDATE(P,StorageName,Module)],true) :- !, flora_storage_check_existence(Module), flora_check_export_registry(ThisModuleName,Module,P,FLEXPORT_UPDATABLE), flora_storage_deleteall(ThisModuleName,P,StorageName). -FLLIBDELETEALL(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,Var,Mod,_Caller)],true) :- +FLLIBDELETEALL(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,Var,ModuleName,_Caller)],true) :- + var(Var), + %% delete any predicate in module ModuleName + !, + findall(FLSYSDBUPDATE(Var,Storage),(flora_construct_delete_predicate(ThisModuleName,ModuleName,Var),flora_fdb_storage_name(ModuleName,Storage)),FsList), + flora_storage_deletelist(ThisModuleName,FsList). + +FLLIBDELETEALL(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Var),Mod,_Caller)],true) :- var(Var), %% delete any tabled predicate in any module !, Index: flrmetaops.P =================================================================== RCS file: /cvsroot/flora/flora2/syslib/flrmetaops.P,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- flrmetaops.P 2 Feb 2005 12:11:12 -0000 1.12 +++ flrmetaops.P 21 Mar 2005 06:55:00 -0000 1.13 @@ -37,12 +37,17 @@ :- import get_canonical_form/2, - convert_to_body_literal/2 + convert_to_body_literal/2, + flora_is_tabled_predicate/1, + flora_is_nontabled_predicate/1 from flrcanon. :- import flora_generalize_last/2 from flrtrim. -:- import flora_list2conjunct/2 from flrutils. +:- import + flora_list2conjunct/2, + flora_abort/1 + from flrutils. #include "flora_terms.flh" @@ -102,30 +107,94 @@ (var(Y) -> X = Y ; - get_canonical_form(Y, FLCANON(_,_,_,X,FL_NOTTABLED)) + ( flora_is_nontabled_predicate(Y) -> + X = Y + ; + flora_abort('non-tabled predicate expected') + ) ). FLLIBUNIVEQFORM(FL_HASHED(X),FL_HASHED(Y)) :- var(Y), !, - get_canonical_form(X, FLCANON(_,_,_,Y,FL_NOTTABLED)). + ( flora_is_nontabled_predicate(X) -> + X = Y + ; + flora_abort('non-tabled predicate expected') + ). FLLIBUNIVEQFORM(FL_HASHED(X),Y) :- !, ( var(X) -> - get_canonical_form(Y, FLCANON(_,_,_,X,FL_NOTTABLED)), - (var(X) -> X=Y; true) + flora_is_nontabled_predicate(Y), + X=Y ; - FLLIBUNIVEQFORM(X,Y) + ( flora_is_nontabled_predicate(X) -> + FLLIBUNIVEQFORM(X,Y) + ; + flora_abort('non-tabled predicate expected') + ) ). FLLIBUNIVEQFORM(X,FL_HASHED(Y)) :- !, ( var(Y) -> - get_canonical_form(X, FLCANON(_,_,_,Y,FL_NOTTABLED)), - (var(Y) -> X=Y; true) + flora_is_nontabled_predicate(X), + X=Y ; - FLLIBUNIVEQFORM(X,Y) + ( flora_is_nontabled_predicate(Y) -> + FLLIBUNIVEQFORM(X,Y) + ; + flora_abort('non-tabled predicate expected') + ) + ). + +FLLIBUNIVEQFORM(FL_EXCL(X),FL_EXCL(Y)) :- + var(X), + !, + (var(Y) -> + X = Y + ; + ( flora_is_tabled_predicate(Y) -> + X = Y + ; + flora_abort('tabled predicate expected') + ) + ). + +FLLIBUNIVEQFORM(FL_EXCL(X),FL_EXCL(Y)) :- + var(Y), + !, + ( flora_is_tabled_predicate(X) -> + X = Y + ; + flora_abort('tabled predicate expected') + ). + +FLLIBUNIVEQFORM(FL_EXCL(X),Y) :- + !, + ( var(X) -> + flora_is_tabled_predicate(Y), + X=Y + ; + ( flora_is_tabled_predicate(X) -> + FLLIBUNIVEQFORM(X,Y) + ; + flora_abort('tabled predicate expected') + ) + ). + +FLLIBUNIVEQFORM(X,FL_EXCL(Y)) :- + !, + ( var(Y) -> + flora_is_tabled_predicate(X), + X=Y + ; + ( flora_is_tabled_predicate(Y) -> + FLLIBUNIVEQFORM(X,Y) + ; + flora_abort('tabled predicate expected') + ) ). FLLIBUNIVEQFORM(X,Y) :- @@ -148,20 +217,70 @@ FLLIBUNIVEQFORM(X,Y), FLLIBUNIVEQFORM(XX,YY). -FLLIBUNIVEQFORM(FLLIBMODLIT(FL_LIBMOD,X,M,_Caller1),FLLIBMODLIT(FL_LIBMOD,Y,M,_Caller2)) :- +FLLIBUNIVEQFORM(FLLIBMODLIT(FL_LIBMOD,X,M,_Caller1),Y) :- + ( var(X) -> + true + ; (atom(X); X=..[WRAP_HILOG|_]) -> + flora_abort('! or # expected') + ; X \= FL_EXCL(_), X \= FL_HASHED(_) + ), + !, + ( get_canonical_form(Y,FLCANON(Wrap,_,Mod,P,_)) -> + ( get_canonical_form(X,FLCANON(_,_,NewMod,_,_)) -> + (nonvar(NewMod) -> Mod=NewMod; M=Mod) + ; + M = Mod + ), + %%( (M==FL_INVALIDMODULE;Mod==FL_INVALIDMODULE) -> true; M = Mod ), + ( nonvar(P) -> + FLLIBUNIVEQFORM(X,P) + ; nonvar(Wrap) -> + FLLIBUNIVEQFORM(X,Y) + ; X = P + ) + ; + FLLIBUNIVEQFORM(X,Y) + ). + +FLLIBUNIVEQFORM(Y,FLLIBMODLIT(FL_LIBMOD,X,M,_Caller1)) :- + ( var(X) -> + true + ; (atom(X); X=..[WRAP_HILOG|_]) -> + flora_abort('! or # expected') + ; X \= FL_EXCL(_), X \= FL_HASHED(_) + ), + !, + ( get_canonical_form(Y,FLCANON(Wrap,_,Mod,P,_)) -> + ( get_canonical_form(X,FLCANON(_,_,NewMod,_,_)) -> + (nonvar(NewMod) -> Mod=NewMod; M=Mod) + ; + M = Mod + ), + %%( (M==FL_INVALIDMODULE;Mod==FL_INVALIDMODULE) -> true; M = Mod ), + ( nonvar(P) -> + FLLIBUNIVEQFORM(X,P) + ; nonvar(Wrap) -> + FLLIBUNIVEQFORM(X,Y) + ; X = P + ) + ; + FLLIBUNIVEQFORM(X,Y) + ). + +FLLIBUNIVEQFORM(FLLIBMODLIT(FL_LIBMOD,FL_EXCL(X),M,_Caller1),FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Y),M,_Caller2)) :- var(X), var(Y), !, X=Y. -%% X ~ #Y fails if both variables are unbound -FLLIBUNIVEQFORM(FLLIBMODLIT(FL_LIBMOD,X,_M1,_Caller1),FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Y),_M2,_Caller2)) :- +%% !X ~ #Y fails +FLLIBUNIVEQFORM(FLLIBMODLIT(FL_LIBMOD,FL_EXCL(X),_M1,_Caller1),FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Y),_M2,_Caller2)) :- var(X), var(Y), !, fail. -FLLIBUNIVEQFORM(FLLIBMODLIT(FL_LIBMOD,FL_HASHED(X),_M1,_Caller1),FLLIBMODLIT(FL_LIBMOD,Y,_M2,_Caller2)) :- +FLLIBUNIVEQFORM(FLLIBMODLIT(FL_LIBMOD,FL_HASHED(X),_M1,_Caller1),FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Y),_M2,_Caller2)) :- var(X), var(Y), !, @@ -173,89 +292,41 @@ !, X=Y. -FLLIBUNIVEQFORM(FLLIBMODLIT(FL_LIBMOD,X,M,C1),FLLIBMODLIT(W,A,M2,C2)) :- +FLLIBUNIVEQFORM(FLLIBMODLIT(FL_LIBMOD,FL_EXCL(X),M,C1),FLLIBMODLIT(W,A,M2,C2)) :- var(X), !, - get_canonical_form(FLLIBMODLIT(W,A,M2,C2),FLCANON(Wrap,Args,M,P,FL_TABLED)), - (var(M2) -> M2 = M; true), + get_canonical_form(FLLIBMODLIT(W,A,M2,C2),FLCANON(Wrap,Args,Mod,P,FL_TABLED)), + ((var(M);M\=FL_INVALIDMODULE,var(Mod)) -> M=Mod; true), (nonvar(P) -> X = P - ; var(Wrap) -> X = A - ; X=FLLIBMODLIT(Wrap,Args,M,C1)). - -FLLIBUNIVEQFORM(FLLIBMODLIT(FL_LIBMOD,X,FL_INVALIDMODULE,_Caller1),Y) :- - var(X), - Y = FLLIBMODLIT(_,_,_,_), - !, - get_canonical_form(Y,FLCANON(_,_,_,_,FL_TABLED)), - X=Y. + ; var(Wrap) -> X = FLLIBMODLIT(W,A,Mod,C1) + ; X=FLLIBMODLIT(Wrap,Args,Mod,C1)). FLLIBUNIVEQFORM(FLLIBMODLIT(FL_LIBMOD,FL_HASHED(X),M,C1),FLLIBMODLIT(W,A,M2,C2)) :- var(X), !, - get_canonical_form(FLLIBMODLIT(W,A,M2,C2),FLCANON(Wrap,Args,M,P,FL_NOTTABLED)), - (var(M2) -> M2 = M; true), + get_canonical_form(FLLIBMODLIT(W,A,M2,C2),FLCANON(Wrap,Args,Mod,P,FL_NOTTABLED)), + ((var(M);M\=FL_INVALIDMODULE,var(Mod)) -> M=Mod; true), (nonvar(P) -> X = P - ; var(Wrap) -> X = A - ; X=FLLIBMODLIT(Wrap,Args,M,C1)). - -FLLIBUNIVEQFORM(FLLIBMODLIT(FL_LIBMOD,FL_HASHED(X),FL_INVALIDMODULE,_Caller1),Y) :- - var(X), - Y = FLLIBMODLIT(_,_,_,_), - !, - get_canonical_form(Y,FLCANON(_,_,_,_,FL_NOTTABLED)), - X=Y. + ; var(Wrap) -> X = FLLIBMODLIT(W,A,M2,C1) + ; X=FLLIBMODLIT(Wrap,Args,Mod,C1)). -FLLIBUNIVEQFORM(FLLIBMODLIT(W,A,M2,C2),FLLIBMODLIT(FL_LIBMOD,Y,M,C1)) :- +FLLIBUNIVEQFORM(FLLIBMODLIT(W,A,M2,C2),FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Y),M,C1)) :- var(Y), !, - get_canonical_form(FLLIBMODLIT(W,A,M2,C2),FLCANON(Wrap,Args,M,P,FL_TABLED)), - (var(M2) -> M2 = M; true), + get_canonical_form(FLLIBMODLIT(W,A,M2,C2),FLCANON(Wrap,Args,Mod,P,FL_TABLED)), + ((var(M);M\=FL_INVALIDMODULE,var(Mod)) -> M=Mod; true), (nonvar(P) -> Y = P - ; var(Wrap) -> Y = A - ; Y=FLLIBMODLIT(Wrap,Args,M,C1)). - -FLLIBUNIVEQFORM(X,FLLIBMODLIT(FL_LIBMOD,Y,FL_INVALIDMODULE,_Caller1)) :- - var(Y), - X = FLLIBMODLIT(_,_,_,_), - !, - get_canonical_form(X,FLCANON(_,_,_,_,FL_TABLED)), - X=Y. + ; var(Wrap) -> Y = FLLIBMODLIT(W,A,M2,C1) + ; Y=FLLIBMODLIT(Wrap,Args,Mod,C1)). FLLIBUNIVEQFORM(FLLIBMODLIT(W,A,M2,C2),FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Y),M,C1)) :- var(Y), !, - get_canonical_form(FLLIBMODLIT(W,A,M2,C2),FLCANON(Wrap,Args,M,P,FL_NOTTABLED)), - (var(M2) -> M2 = M; true), + get_canonical_form(FLLIBMODLIT(W,A,M2,C2),FLCANON(Wrap,Args,Mod,P,FL_NOTTABLED)), + ((var(M);M\=FL_INVALIDMODULE,var(Mod)) -> M=Mod; true), (nonvar(P) -> Y = P - ; var(Wrap) -> Y = A - ; Y=FLLIBMODLIT(Wrap,Args,M,C1)). - -FLLIBUNIVEQFORM(X,FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Y),FL_INVALIDMODULE,_Caller1)) :- - var(Y), - X = FLLIBMODLIT(_,_,_,_), - !, - get_canonical_form(X,FLCANON(_,_,_,_,FL_NOTTABLED)), - X=Y. - -FLLIBUNIVEQFORM((X,XX),FLLIBMODLIT(FL_LIBMOD,(Y,YY),M,_Caller)) :- - !, - FLLIBUNIVEQFORM(X,FLLIBMODLIT(FL_LIBMOD,Y,M,_Caller)), - FLLIBUNIVEQFORM(XX,FLLIBMODLIT(FL_LIBMOD,YY,M,_Caller)). - -FLLIBUNIVEQFORM(FLLIBMODLIT(FL_LIBMOD,(X,XX),M,_Caller), (Y,YY)) :- - !, - FLLIBUNIVEQFORM(FLLIBMODLIT(FL_LIBMOD,X,M,_Caller),Y), - FLLIBUNIVEQFORM(FLLIBMODLIT(FL_LIBMOD,XX,M,_Caller),YY). - -FLLIBUNIVEQFORM((X;XX),FLLIBMODLIT(FL_LIBMOD,(Y;YY),M,_Caller)) :- - !, - FLLIBUNIVEQFORM(X,FLLIBMODLIT(FL_LIBMOD,Y,M,_Caller)), - FLLIBUNIVEQFORM(XX,FLLIBMODLIT(FL_LIBMOD,YY,M,_Caller)). - -FLLIBUNIVEQFORM(FLLIBMODLIT(FL_LIBMOD,(X;XX),M,_Caller), (Y;YY)) :- - !, - FLLIBUNIVEQFORM(FLLIBMODLIT(FL_LIBMOD,X,M,_Caller),Y), - FLLIBUNIVEQFORM(FLLIBMODLIT(FL_LIBMOD,XX,M,_Caller),YY). + ; var(Wrap) -> Y = FLLIBMODLIT(W,A,M2,C1) + ; Y=FLLIBMODLIT(Wrap,Args,Mod,C1)). %% Now neither X nor Y are variables Index: flrbtdbop.P =================================================================== RCS file: /cvsroot/flora/flora2/syslib/flrbtdbop.P,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- flrbtdbop.P 2 Feb 2005 12:11:11 -0000 1.23 +++ flrbtdbop.P 21 Mar 2005 06:54:59 -0000 1.24 @@ -67,7 +67,9 @@ :- import get_canonical_form/2, - convert_to_head_literal/2 + convert_to_head_literal/2, + flora_is_tabled_predicate/1, + flora_is_nontabled_predicate/1 from flrcanon. :- import flora_refresh_tables/1 from flrtables. @@ -125,39 +127,156 @@ !, flora_abort('Uninstantiated argument in btinsert{...}'). +flora_storage_insertfacts_bt(_ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Var),_ModuleName1,_Caller)|_T]) :- + var(Var), + !, + flora_abort('Uninstantiated argument in btinsert{...}'). + flora_storage_insertfacts_bt(_ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Var),_ModuleName1,_Caller)|_T]) :- var(Var), !, flora_abort('Uninstantiated argument in btinsert{...}'). -flora_storage_insertfacts_bt(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,(First,Rest),ModuleName1,Caller)|T]) :- - !, +flora_storage_insertfacts_bt(ThisModuleName,[(First,Rest)|T]) :- + !, ( Rest = FLLIBMODOBJ(_F,_A,_MN,_C,O) -> Rest, ( var(O) -> - flora_abort(['Uninstantiated predicate in an argument positition in btinsert{...}']) + flora_abort(['Uninstantiated predicate in an argument positition + in insert{...}']) ; - flora_storage_insertfacts_bt(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,First,ModuleName1,Caller)]) + flora_storage_insertfacts_bt(ThisModuleName,[First]) + ) + ; Rest = ','(FLLIBMODOBJ(F,A,MN,C,O),R1) -> + FLLIBMODOBJ(F,A,MN,C,O), + ( var(O) -> + flora_abort(['Uninstantiated predicate in an argument positition + in insert{...}']) + ; + flora_storage_insertfacts_bt(ThisModuleName,[','(First,R1)]) ) ; %% For cases such as - %% X = ','(a,b), btinsert{X} - flora_storage_insertfacts_bt(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,First,ModuleName1,Caller)]), - flora_storage_insertfacts_bt(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,Rest,ModuleName1,Caller)]) + %% X = ','(a,b), insert{X} + flora_storage_insertfacts_bt(ThisModuleName,[First,Rest]) ), - flora_storage_insertfacts_bt(ThisModuleName,T). + flora_storage_insertfacts_bt(ThisModuleName,T). -%% btinsert{#X} where X is bound flora_storage_insertfacts_bt(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Arg),Module,_Caller)|T]) :- Module==FL_INVALIDMODULE, !, - flora_storage_insertfacts_bt(ThisModuleName,[Arg|T]). + ( flora_is_nontabled_predicate(Arg) -> + ( Arg = ','(First,Rest) -> + %% Rest is conjunction of 0 to more fllibmobobj + flora_storage_insertfacts_bt(ThisModuleName,[Rest,First|T]) + ; + flora_storage_insertfacts_bt(ThisModuleName,[Arg|T]) + ) + ; + flora_abort(['non-tabled predicate expected']) + ). -%% btinsert{X} where X is bound -flora_storage_insertfacts_bt(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,Arg,Module,_Caller)|T]) :- +flora_storage_insertfacts_bt(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Arg),Module,Caller)|T]) :- + %% #X@M + !, + ( (atom(Arg); Arg =.. [WRAP_HILOG|_]) -> + %% a term + P2H_CONVERSION(Module,ModuleName1), + flora_storage_check_module_name(ModuleName1), + (get_canonical_form(FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Arg),Module,Caller), FLCANON(_,_,_,P,_)) -> true + ; + flora_decode_goal_as_atom(Arg,AtomArg), + flora_abort(['A non-fact found in insert{...}, ', AtomArg]) + ), + convert_to_head_literal(P,HeadP), + flora_fdb_storage_name(ModuleName1,StorageName), + flora_internal_db_insert_bt(StorageName,HeadP), + flora_storage_insertfacts_bt(ThisModuleName,T) + + ; flora_is_nontabled_predicate(Arg) -> + %% a non-tabled predicate + ( Arg = ','(First,Rest) -> + %% Rest is conjunction of 0 to more fllibmobobj + flora_storage_insertfacts_bt(ThisModuleName,[Rest,First|T]) + ; + flora_storage_insertfacts_bt(ThisModuleName,[Arg|T]) + ) + ; + flora_abort(['term or non-tabled predicate expected']) + ). + +flora_storage_insertfacts_bt(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Arg),Module,_Caller)|T]) :- Module==FL_INVALIDMODULE, !, - flora_storage_insertfacts_bt(ThisModuleName,[Arg|T]). + ( flora_is_tabled_predicate(Arg) -> + ( Arg = ','(First,Rest) -> + %% Rest is conjunction of 0 to more fllibmobobj + flora_storage_insertfacts_bt(ThisModuleName,[Rest,First|T]) + ; + flora_storage_insertfacts_bt(ThisModuleName,[Arg|T]) + ) + ; + flora_abort(['tabled predicate expected']) + ). + +flora_storage_insertfacts_bt(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Arg),Module,Caller)|T]) :- + %% !X@M + !, + ( (atom(Arg); Arg =.. [WRAP_HILOG|_]) -> + %% a term + P2H_CONVERSION(Module,ModuleName1), + flora_storage_check_module_name(ModuleName1), + (get_canonical_form(FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Arg),Module,Caller), FLCANON(_,_,_,P,_)) -> true + ; + flora_decode_goal_as_atom(Arg,AtomArg), + flora_abort(['A non-fact found in insert{...}, ', AtomArg]) + ), + convert_to_head_literal(P,HeadP), + flora_fdb_storage_name(ModuleName1,StorageName), + flora_internal_db_insert_bt(StorageName,HeadP), + flora_storage_insertfacts_bt(ThisModuleName,T) + + ; flora_is_tabled_predicate(Arg) -> + %% a tabled predicate + ( Arg = ','(First,Rest) -> + %% Rest is conjunction of 0 to more fllibmobobj + flora_storage_insertfacts_bt(ThisModuleName,[Rest,First|T]) + ; + flora_storage_insertfacts_bt(ThisModuleName,[Arg|T]) + ) + ; + flora_abort(['term or tabled predicate expected']) + ). + +flora_storage_insertfacts_bt(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,Arg,Module,Caller)|T]) :- + %% X@M + !, + ( (atom(Arg); Arg =.. [WRAP_HILOG|_]) -> + flora_abort('! or # expected') + + ; Arg = ','(First,Rest) -> + ( Rest = FLLIBMODOBJ(_F,_A,_MN,_C,O) -> + Rest, + ( var(O) -> + flora_abort(['Uninstantiated predicate in an argument positition in insert{...}']) + ; + flora_storage_insertfacts_bt(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,First,Module,Caller)]) + ) + ; Rest = ','(FLLIBMODOBJ(F,A,MN,C,O),R1) -> + FLLIBMODOBJ(F,A,MN,C,O), + ( var(O) -> + flora_abort(['Uninstantiated predicate in an argument positition in insert{...}']) + ; + flora_storage_insertfacts_bt(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,','(First,R1),Module,Caller)]) + ) + ; + flora_storage_insertfacts_bt(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,First,ModuleName1,Caller)]), + flora_storage_insertfacts_bt(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,Rest,ModuleName1,Caller)]) + ) + ; + flora_storage_insertfacts_bt(ThisModuleName,[Arg]) + ), + flora_storage_insertfacts_bt(ThisModuleName,T). flora_storage_insertfacts_bt(ThisModuleName,[FLLIBMODLIT(F,Args,ModuleName1,Caller)|T]) :- !, @@ -265,6 +384,18 @@ The semantics is such that all the literals in "List" must be base facts in the storage to be deleted. *****************************************************************************/ +FLLIBBTDELETE(ThisModuleName,[Var],true) :- + var(Var), + %% btdelete any predicate in any module + !, + flora_module_registry(ModuleName), + flora_fdb_storage_name(ModuleName,StorageName), + flora_check_export_registry_internal(ThisModuleName,ModuleName,Var,FLEXPORT_UPDATABLE), + flora_db_find_base(StorageName,Var), + flora_add_last(Var,NP,ThisModuleName), + !, + flora_internal_db_delete_bt(StorageName,NP). + FLLIBBTDELETE(ThisModuleName,[FLSYSDBUPDATE(P,StorageName,Module)],true) :- !, flora_storage_check_existence(Module), @@ -272,7 +403,25 @@ flora_db_find_base(StorageName,P), flora_internal_db_delete_bt(StorageName,P). -FLLIBBTDELETE(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,Var,Mod,_Caller)],true) :- +FLLIBBTDELETE(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,Var,ModuleName,_Caller)],true) :- + var(Var), + %% btdelete any predicate in any module ModuleName + !, + flora_module_registry(ModuleName), + flora_fdb_storage_name(ModuleName,StorageName), + flora_check_export_registry_internal(ThisModuleName,ModuleName,P,FLEXPORT_UPDATABLE), + ( var(P) -> + flora_db_find_base(StorageName,P), + flora_add_last(P,NP,ThisModuleName) + ; + flora_db_find_base(StorageName,P), + NP = P + ), + get_canonical_form(NP,FLCANON(_,_,_,Var,_)), + !, + flora_internal_db_delete_bt(StorageName,NP). + +FLLIBBTDELETE(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Var),Mod,_Caller)],true) :- var(Var), %% btdelete any tabled predicate in any module !, @@ -295,6 +444,35 @@ !, flora_internal_db_delete_bt(StorageName,NP). +FLLIBBTDELETE(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Pred),Mod,Caller)],true) :- + !, + %% delete{!X} or delete{!X@M} where X is bound + ( Mod == FL_INVALIDMODULE -> + ( flora_is_tabled_predicate(Pred) -> + true + ; + flora_abort('tabled predicate expected') + ) + ; + ( (atom(Pred);Pred=..[WRAP_HILOG|_];flora_is_tabled_predicate(Pred)) -> + true + ; + flora_abort('term or tabled predicate expected') + ) + ), + ( Pred = ','(First,Rest) -> + %% Rest is the conjunction of 1 to more fllibmodobj + get_canonical_form(First,FLCANON(_,_,NewMod,NP,_)) + ; + get_canonical_form(FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Pred),Mod,Caller),FLCANON(_,_,NewMod,NP,_)) + ), + flora_storage_check_existence(NewMod), + flora_check_export_registry(ThisModuleName,NewMod,NP,FLEXPORT_UPDATABLE), + flora_fdb_storage_name(NewMod,StorageName), + flora_db_find_base(StorageName,NP), + ( nonvar(Rest) -> Rest ; true), + flora_internal_db_delete_bt(StorageName,NP). + FLLIBBTDELETE(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Var),Mod,_Caller)],true) :- var(Var), %% btdelete any non-tabled predicate in any module @@ -318,6 +496,35 @@ !, flora_internal_db_delete_bt(StorageName,NP). +FLLIBBTDELETE(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Pred),Mod,Caller)],true) :- + !, + %% delete{#X} or delete{#X@M} where X is bound + ( Mod == FL_INVALIDMODULE -> + ( flora_is_nontabled_predicate(Pred) -> + true + ; + flora_abort('non-tabled predicate expected') + ) + ; + ( (atom(Pred);Pred=..[WRAP_HILOG|_];flora_is_nontabled_predicate(Pred)) -> + true + ; + flora_abort('term or non-tabled predicate expected') + ) + ), + ( Pred = ','(First,Rest) -> + %% Rest is the conjunction of 1 to more fllibmodobj + get_canonical_form(First,FLCANON(_,_,NewMod,NP,_)) + ; + get_canonical_form(FLLIBMODLIT(FL_LIBMOD,FL_HASHED(Pred),Mod,Caller),FLCANON(_,_,NewMod,NP,_)) + ), + flora_storage_check_existence(NewMod), + flora_check_export_registry(ThisModuleName,NewMod,NP,FLEXPORT_UPDATABLE), + flora_fdb_storage_name(NewMod,StorageName), + flora_db_find_base(StorageName,NP), + ( nonvar(Rest) -> Rest ; true), + flora_internal_db_delete_bt(StorageName,NP). + FLLIBBTDELETE(ThisModuleName,List,Condition) :- flora_storage_convertlist(ThisModuleName,List,CallList,FactList), flora_list2conjunct([Condition|CallList],Goal), @@ -367,13 +574,27 @@ The semantics is such that all the literals in "List" must be base facts in the storage to be deleted. This call always succeeds. *****************************************************************************/ +FLLIBBTDELETEALL(ThisModuleName,[Var],true) :- + var(Var), + %% delete any predicate in any module + !, + findall(FLSYSDBUPDATE(Var,Storage),(flora_construct_delete_predicate(ThisModuleName,ModuleName,Var),flora_fdb_storage_name(ModuleName,Storage)),FsList), + flora_storage_deletelist_bt(ThisModuleName,FsList). + FLLIBBTDELETEALL(ThisModuleName,[FLSYSDBUPDATE(P,StorageName,Module)],true) :- !, flora_storage_check_existence(Module), flora_check_export_registry(ThisModuleName,Module,P,FLEXPORT_UPDATABLE), flora_storage_deleteall_bt(ThisModuleName,P,StorageName). -FLLIBBTDELETEALL(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,Var,Mod,_Caller)],true) :- +FLLIBBTDELETEALL(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,Var,ModuleName,_Caller)],true) :- + var(Var), + %% btdelete any predicate in module ModuleName + !, + findall(FLSYSDBUPDATE(Var,Storage),(flora_construct_delete_predicate(ThisModuleName,ModuleName,Var),flora_fdb_storage_name(ModuleName,Storage)),FsList), + flora_storage_deletelist_bt(ThisModuleName,FsList). + +FLLIBBTDELETEALL(ThisModuleName,[FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Var),Mod,_Caller)],true) :- var(Var), %% btdelete any tabled predicate in any module !, Index: flrcanon.P =================================================================== RCS file: /cvsroot/flora/flora2/syslib/flrcanon.P,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- flrcanon.P 2 Feb 2005 12:11:12 -0000 1.20 +++ flrcanon.P 21 Mar 2005 06:54:59 -0000 1.21 @@ -74,7 +74,9 @@ flora_build_pred_signature/2, flora_restore_from_signature/2, flora_preprocess_headlist/2, - flora_reset_rule_signature/1. + flora_reset_rule_signature/1, + flora_is_nontabled_predicate/1, + flora_is_tabled_predicate/1. /****************************************************************************** get_canonical_form(+Term,-Canon) @@ -82,7 +84,7 @@ of FLCANON(Wrap,Args,Module,Callable) ******************************************************************************/ %% Case of Var -get_canonical_form(Term,FLCANON(_,_,_,Term,FL_TABLED)) :- +get_canonical_form(Term,FLCANON(_,_,_,Term,_)) :- var(Term), !. @@ -90,6 +92,12 @@ get_canonical_form(FLLIBMODLIT(FL_LIBMOD,Term,Mod,_Caller),Canon) :- var(Term), !, + Canon = FLCANON(_,_,Mod,Term,_). + +%% Case of !Var@... +get_canonical_form(FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Term),Mod,_Caller),Canon) :- + var(Term), + !, Canon = FLCANON(_,_,Mod,Term,FL_TABLED). %% Case of #Var@... @@ -112,11 +120,19 @@ Canon = FLCANON(WRAP_HILOG,ArgsOut,Mod,Callable,FL_NOTTABLED) ) ; is_flora_callable_literal(Term) -> - get_canonical_form(Term,Canon) + ( get_canonical_form(Term,FLCANON(NW,NA,NM,NC,FL_NOTTABLED)) -> + Canon = FLCANON(NW,NA,NM,NC,FL_NOTTABLED) + ; + flora_abort('non-tabled predicate expected') + ) ; Term = FLLIBMODLIT(_W,_A,_M,_C) -> get_canonical_form(Term,Canon), - Canon = FLCANON(_NW,_NA,NM,_NC,_NF), - ( (Mod==FL_INVALIDMODULE;nonvar(NM)) -> true; NM=Mod) + Canon = FLCANON(_NW,_NA,NM,_NC,NF), + (NF = FL_NOTTABLED -> + ( (Mod==FL_INVALIDMODULE;nonvar(NM)) -> true; NM=Mod) + ; + flora_abort('non-tabled predicate expected') + ) ; Term =.. [WRAP_HILOG|As] -> append(As,[_],ArgsOut), ( var(Mod) -> @@ -129,8 +145,8 @@ ) ). -%% Case of Var@... where Var is bound -get_canonical_form(FLLIBMODLIT(FL_LIBMOD,Term,Mod,_Caller),Canon) :- +%% Case of !Var@... where Var is bound +get_canonical_form(FLLIBMODLIT(FL_LIBMOD,FL_EXCL(Term),Mod,_Caller),Canon) :- !, ( atom(Term) -> ArgsOut=[Term,_], @@ -143,11 +159,19 @@ Canon = FLCANON(WRAP_TABLED_HILOG,ArgsOut,Mod,Callable,FL_TABLED) ) ; is_flora_callable_literal(Term) -> - get_canonical_form(Term,Canon) + ( get_canonical_form(Term,FLCANON(NW,NA,NM,NC,FL_TABLED)) -> + Canon = FLCANON(NW,NA,NM,NC,FL_TABLED) + ; + flora_abort('tabled predicate expected') + ) ; Term = FLLIBMODLIT(_W,_A,_M,_C) -> get_canonical_form(Term,Canon), - Canon = FLCANON(_NW,_NA,NM,_NC,_NF), - ( (Mod==FL_INVALIDMODULE;nonvar(NM)) -> true; NM=Mod) + Canon = FLCANON(_NW,_NA,NM,_NC,NF), + (NF = FL_TABLED -> + ( (Mod==FL_INVALIDMODULE;nonvar(NM)) -> true; NM=Mod) + ; + flora_abort('tabled predicate expected') + ) ; Term =.. [WRAP_HILOG|As] -> append(As,[_],ArgsOut), ( var(Mod) -> @@ -160,6 +184,21 @@ ) ). +%% Case of Var@... where Var is bound +get_canonical_form(FLLIBMODLIT(FL_LIBMOD,Term,Mod,_Caller),Canon) :- + !, + ( atom(Term) -> + flora_abort('! or # expected') + ; is_flora_callable_literal(Term) -> + get_canonical_form(Term,Canon) + ; Term = FLLIBMODLIT(_W,_A,_M,_C) -> + get_canonical_form(Term,Canon), + Canon = FLCANON(_NW,_NA,NM,_NC,_NF), + ( (Mod==FL_INVALIDMODULE;nonvar(NM)) -> true; NM=Mod) + ; Term =.. [WRAP_HILOG|_As] -> + flora_abort('! or # expected') + ). + %% Case of nonvar@Var get_canonical_form(FLLIBMODLIT(Wrap,Args,Mod,_Caller), Canon) :- !, @@ -604,3 +643,26 @@ flora_generalize_last(HH,GH), flora_rule_signature(Prefix,GH,NewBody,RuleList,BridgeRule), FLLIBUNIVEQFORM(NewBody,Body). + +/*********************************************************************** + flora_is_nontabled_predicate(+Predicate) +************************************************************************/ +flora_is_nontabled_predicate(Predicate) :- + conjunct_to_list(Predicate,[H|L]), + get_canonical_form(H,FLCANON(_,_,_,_,FL_NOTTABLED)), + only_fllibmodobj(L). + +/*********************************************************************** + flora_is_tabled_predicate(+Predicate) +************************************************************************/ +flora_is_tabled_predicate(Predicate) :- + conjunct_to_list(Predicate,[H|L]), + get_canonical_form(H,FLCANON(_,_,_,_,FL_TABLED)), + only_fllibmodobj(L). + +/*********************************************************************** + only_fllibmodobj(+List) +************************************************************************/ +only_fllibmodobj([]) :- !. +only_fllibmodobj([FLLIBMODOBJ(_,_,_,_,_)|L]) :- + only_fllibmodobj(L). Index: flrdynmod.P =================================================================== RCS file: /cvsroot/flora/flora2/syslib/flrdynmod.P,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- flrdynmod.P 12 Mar 2005 06:35:08 -0000 1.25 +++ flrdynmod.P 21 Mar 2005 06:55:00 -0000 1.26 @@ -85,7 +85,9 @@ %% If module is a variable, we must protect the call %% from undefinedness checks (var(ModuleName) -> ProtectCall = true ; true), - (var(Arg) -> + ( + %% is this possible? + var(Arg) -> (ModuleName==FL_INVALIDMODULE -> flora_abort([Arg,': Attempt to call uninstantiated literal']) ; @@ -99,6 +101,13 @@ flora_abort(['#',NA,'@',ModuleName,': Attempt to call uninstantiated literal']) ) + ; Arg=FL_EXCL(NA), var(NA) -> + (ModuleName==FL_INVALIDMODULE -> + flora_abort(['!',NA,': Attempt to call uninstantiated literal']) + ; + flora_abort(['!',NA,'@',ModuleName,': Attempt to call uninstantiated literal']) + ) + ; flora_check_module_name(ModuleName), ( get_libmod_callable(F,Arg,ModuleName,CallerInfo,P) -> %% Assign an Id to be used by both the export & the @@ -158,8 +167,8 @@ *********************************************************************/ FLLIBMODOBJ(F,Arg,ModuleName,CallerInfo,Pout) :- ( nonvar(Pout) -> - FLLIBUNIVEQFORM(FLLIBMODLIT(F,Arg,ModuleName,CallerInfo),Pout) - ; (var(Arg);Arg=FL_HASHED(NA),var(NA)) -> + FLLIBUNIVEQFORM(FLLIBMODLIT(F,Arg,ModuleName,CallerInfo),Pout) + ; (var(Arg);Arg=FL_HASHED(NA),var(NA);Arg=FL_EXCL(NA),var(NA)) -> true ; F \= FL_LIBMOD, var(ModuleName) -> true @@ -230,7 +239,7 @@ ) ). -get_libmod_callable(F,Arg,ModuleName,CallerInfo,P) :- +get_libmod_callable(F,FL_EXCL(Arg),ModuleName,CallerInfo,P) :- ( is_list(Arg), !, % Term@X %% This case is compiled as FLLIBMODLIT(F,Args,WS,CallerInfo) @@ -288,6 +297,52 @@ ) ). +get_libmod_callable(F,Arg,ModuleName,CallerInfo,P) :- + ( + is_list(Arg), !, % Term@X + %% This case is compiled as FLLIBMODLIT(F,Args,WS,CallerInfo) + %% so the caller is already accounted for + %% P is now made into a Flora wrapper + flora_module_predicate(F,Arg,ModuleName,P), + make_caller_info(CallerInfo,ModuleName,RealCallerInfo), + flora_bind_last(P, RealCallerInfo) + ; is_libmodlit_control(Arg, [_Wrap,_A,PredModule,_C]), !, + make_caller_info(CallerInfo,PredModule,RealCallerInfo), + flora_bind_last(Arg, RealCallerInfo), + Arg = P + %% is_caller_distributive/3 + ; is_caller_distributive(Arg, _, _), !, + apply_caller_info(Arg,CallerInfo,P) + %% is_caller_distributive/4 + ; is_caller_distributive(Arg, _, _, _), !, + apply_caller_info(Arg,CallerInfo,P) + %% is_ws_distributive/3 + ; is_ws_distributive(Arg,Op,ArgList), !, + distribute_workspace(F,ArgList,ModuleName,CallerInfo,ArgListOut), + is_ws_distributive(P,Op,ArgListOut) + ; %% Var@..., Var bound to compound + flora_decode_predicate(Arg,_,PredModName,Wrapper,_,_,_Args), !, + ( %% if already a hilog or flogic predicate -- use it + nonvar(PredModName), + %% Arg is already a FLORA callable predicate, + %% so use *its* module name, NOT the one from CallerInfo + make_caller_info(CallerInfo,PredModName,RealCallerInfo), + flora_bind_last(Arg, RealCallerInfo), + Arg = P, + ! + ; ModuleName==FL_INVALIDMODULE, + Arg = P, + ! + ; %% else construct it + ( (atom(Arg); Wrapper == WRAP_HILOG) -> + flora_abort('! or # expected') + ; + %% Var@... where Var bound to a prolog predicate + Arg = P + ) + ) + ). + is_ws_distributive(','(B1,B2),',',[B1,B2]). is_ws_distributive(';'(B1,B2),';',[B1,B2]). |
|
From: Chang Z. <ch...@us...> - 2005-03-21 06:52:28
|
Update of /cvsroot/flora/flora-testsuite/exporttest In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2545/exporttest Modified Files: encap_mod1.flr Log Message: introduce variables prefixed with ! for tabled predicates Index: encap_mod1.flr =================================================================== RCS file: /cvsroot/flora/flora-testsuite/exporttest/encap_mod1.flr,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- encap_mod1.flr 5 Sep 2004 06:30:40 -0000 1.3 +++ encap_mod1.flr 21 Mar 2005 06:52:16 -0000 1.4 @@ -44,7 +44,7 @@ /******** simple predicate exported as updatable *********/ #tst11 :- - _A=p(X), _A@encap_mod2, + _A=p(X), !_A@encap_mod2, write('test 11, query ')@prolog(), write(x=X)@prolog(), writeln(' succeeded, as expected')@prolog(). |
|
From: Chang Z. <ch...@us...> - 2005-03-21 06:52:28
|
Update of /cvsroot/flora/flora-testsuite/general_tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2545/general_tests Modified Files: hashtest.flr meta_unification.flr metaupdates.flr reif.flr tabletest.flr Log Message: introduce variables prefixed with ! for tabled predicates Index: hashtest.flr =================================================================== RCS file: /cvsroot/flora/flora-testsuite/general_tests/hashtest.flr,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- hashtest.flr 2 Feb 2005 12:04:39 -0000 1.1 +++ hashtest.flr 21 Mar 2005 06:52:16 -0000 1.2 @@ -5,7 +5,7 @@ #tst2 :- #X ~ #p(a), write('tst2 succeeded, as expected = ')@prolog(), flora_write_goal(ans(X))@prolog(flrdecode), nl@prolog(). -#tst3 :- unless (X=p(a), #X ~ #p(a)) +#tst3 :- unless (X=p(a), X ~ p(a)) do writeln('tst3 failed as expected')@prolog(). #tst4 :- unless #_X ~ p(a) do writeln('tst4 failed as expected')@prolog(). @@ -18,17 +18,17 @@ #tst7 :- X ~ a[b->c]@foo, write('tst7 succeeded, as expected = ')@prolog(), flora_write_goal(ans(X))@prolog(flrdecode), nl@prolog(). -#tst8 :- unless _X@_M ~ #p(a) +#tst8 :- unless !_X@_M ~ #p(a) do writeln('tst8 failed as expected')@prolog(). -#tst9 :- unless _X@foo ~ a[#b]@_M +#tst9 :- unless !_X@foo ~ a[#b]@_M do writeln('tst9 failed as expected')@prolog(). #tst10 :- insert{p(a),#q(b)}, - delete{X}, + delete{!X}, delete{#Y}, write('tst10 succeeded, as expected = ')@prolog(), flora_write_goal(ans(X,Y))@prolog(flrdecode), nl@prolog(). #tst11 :- insert{p(${a}),p(${#b})}, - p(${X}), + p(${!X}), p(${#Y@M}), deleteall{p(_)}, write('tst11 succeeded, as expected = ')@prolog(), @@ -45,19 +45,19 @@ flora_write_goal(ans(X,Y))@prolog(flrdecode), nl@prolog(). #tst14 :- unless clause{dynamic,_X,#_Y} do writeln('tst14 failed as expected')@prolog(). -#tst15 :- unless clause{dynamic,#_X,_Y@_M} +#tst15 :- unless clause{dynamic,#_X,!_Y@_M} do writeln('tst15 failed as expected')@prolog(). -#tst16 :- X ~ p(a), #X ~ p(a), #Y ~ a[#b], Y ~ a[#b], +#tst16 :- !X ~ p(a), X ~ p(a), #Y ~ a[#b], Y ~ a[#b], write('tst16 succeeded, as expected = ')@prolog(), flora_write_goal(ans(X,Y))@prolog(flrdecode), nl@prolog(). -#tst17 :- unless (X ~ p(a), #X ~ #p(a), #X ~ #p(a), X ~ p(a)) +#tst17 :- unless (X ~ p(a), X ~ #p(a)) do writeln('tst17 failed as expected')@prolog(). #tst18 :- unless (X ~ p@_M, Y ~ p@foo, pp(X) ~ pp(Y)) do writeln('tst18 failed as expected')@prolog(). -#tst19 :- X ~ p@M, Y ~ p@foo, pp(${X}) ~ pp(${Y}), +#tst19 :- X ~ p@M, Y ~ p@foo, pp(${!X}) ~ pp(${!Y}), write('tst19 succeeded, as expected = ')@prolog(), flora_write_goal(ans(X,M,Y))@prolog(flrdecode), nl@prolog(). -#tst20 :- X ~ p, #Y ~ #q@M, pp(${X},${Y}) ~ pp(${p@M2}, ${#Z@foo}), +#tst20 :- X ~ p, #Y ~ #q@M, pp(X,${#Y}) ~ pp(${p@M2}, ${#Z@foo}), write('tst20 succeeded, as expected = ')@prolog(), flora_write_goal(ans(X,Y,M,M2,Z))@prolog(flrdecode), nl@prolog(). #tst21 :- pp(${p@M1},${#q@foo}) ~ pp(${X@main}, ${#Z@M2}), Index: meta_unification.flr =================================================================== RCS file: /cvsroot/flora/flora-testsuite/general_tests/meta_unification.flr,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- meta_unification.flr 2 Feb 2005 12:07:44 -0000 1.7 +++ meta_unification.flr 21 Mar 2005 06:52:16 -0000 1.8 @@ -2,7 +2,7 @@ do writeln('tst1 failed as expected')@prolog(). #tst1_2 :- unless #a(b) ~ #_X@foo do writeln('tst1_2 failed as expected')@prolog(). -#tst2 :- a(b)@foo ~ X@foo, Y = foo, a(b)@Y ~ X@foo, Z=a(b), Z@Y ~ X@foo, +#tst2 :- a(b)@foo ~ X@foo, Y = foo, a(b)@Y ~ X@foo, Z=a(b), !Z@Y ~ X@foo, a(b)@foo ~ XX@YY, write('tst2 succeeded, as expected = ')@prolog(), flora_write_goal(ans(X,XX,YY))@prolog(flrdecode), nl@prolog(). @@ -12,7 +12,7 @@ flora_write_goal(ans(X,XX,YY))@prolog(flrdecode), nl@prolog(). #tst3 :- _X@M ~ Y@foo, Z@foo ~ V@N, Z=a, Y=a(b), write('tst3 succeeded, as expected = ')@prolog(), - flora_write_goal(ans(${_X@M}, ${V@N}))@prolog(flrdecode), nl@prolog(). + flora_write_goal(ans(${!_X@M}, ${!V@N}))@prolog(flrdecode), nl@prolog(). #tst3_2 :- #_X@M ~ #Y@foo, #Z@foo ~ #V@N, Z=a, Y=a(b), write('tst3_2 succeeded, as expected = ')@prolog(), flora_write_goal(ans(${#_X@M}, ${#V@N}))@prolog(flrdecode), nl@prolog(). @@ -24,15 +24,15 @@ #tst5_2 :- #a(b)@M ~ #X@bar, #Y@bar ~ #a(b)@MM, write('tst5_2 succeeded, as expected = ')@prolog(), flora_write_goal(ans(X,M,Y,MM))@prolog(flrdecode), nl@prolog(). -#tst6 :- X@M ~ Y@foo, Y=a(b), X@M~a(b)@foo, +#tst6 :- !X@M ~ Y@foo, Y=a(b), !X@M~a(b)@foo, write('tst6 succeeded, as expected = ')@prolog(), - flora_write_goal(ans(${X@M},Y))@prolog(flrdecode), nl@prolog(). + flora_write_goal(ans(${!X@M},Y))@prolog(flrdecode), nl@prolog(). #tst6_2 :- #X@M ~ #Y@foo, Y=a(b), #X@M~ #a(b)@foo, write('tst6_2 succeeded, as expected = ')@prolog(), flora_write_goal(ans(${#X@M}))@prolog(flrdecode), nl@prolog(). -#tst7 :- X@M ~ Y@foo, Y=a(b), Y@Z ~a(b)@W, W=bar, +#tst7 :- X@M ~ Y@foo, Y=a(b), !Y@Z ~a(b)@W, W=bar, write('tst7 succeeded, as expected = ')@prolog(), - flora_write_goal(ans(${X@M},Y,Z,W))@prolog(flrdecode), nl@prolog(). + flora_write_goal(ans(${!X@M},Y,Z,W))@prolog(flrdecode), nl@prolog(). #tst7_2 :- #X@M ~ #Y@foo, Y=a(b), #Y@Z ~ #a(b)@W, W=bar, write('tst7_2 succeeded, as expected = ')@prolog(), flora_write_goal(ans(${#X@M},Y,Z,W))@prolog(flrdecode), nl@prolog(). Index: reif.flr =================================================================== RCS file: /cvsroot/flora/flora-testsuite/general_tests/reif.flr,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- reif.flr 2 Feb 2005 12:07:44 -0000 1.4 +++ reif.flr 21 Mar 2005 06:52:16 -0000 1.5 @@ -74,7 +74,7 @@ X, flora_write_goal(X)@prolog(flrdecode), nl@prolog(), - X~ _(_,Caller)@ _M, + X~ !_(_,Caller)@ _M, if Caller==main then writeln(tst6=ok)@prolog() else writeln(tst6=failed)@prolog(). Index: metaupdates.flr =================================================================== RCS file: /cvsroot/flora/flora-testsuite/general_tests/metaupdates.flr,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- metaupdates.flr 2 Feb 2005 12:07:44 -0000 1.6 +++ metaupdates.flr 21 Mar 2005 06:52:16 -0000 1.7 @@ -13,12 +13,12 @@ #tst4 :- write('tst4: ')@prolog(), X= ${a@main}, p(Y), X = Y, flora_write_goal(X)@prolog(flrdecode), nl@prolog(). -#tst5 :- write('tst5: ')@prolog(), Y=a, Z=main, X = ${pp(${Y@Z})}, insert{X}, +#tst5 :- write('tst5: ')@prolog(), Y=a, Z=main, X = ${pp(${!Y@Z})}, insert{X}, flora_write_goal(X)@prolog(flrdecode), nl@prolog(). #tst6 :- write('tst6: ')@prolog(), pp(X), flora_write_goal(X)@prolog(flrdecode), nl@prolog(), X = ${a@main}. -#tst7 :- write('tst7: ')@prolog(), Y= a, Z=main, insert{qq(${Y@Z})}, +#tst7 :- write('tst7: ')@prolog(), Y= a, Z=main, insert{qq(${!Y@Z})}, writeln(' done')@prolog(). #tst8 :- write('tst8: ')@prolog(), qq(X), flora_write_goal(X)@prolog(flrdecode), nl@prolog(), X = ${a@main}. @@ -40,12 +40,12 @@ #tst12 :- write('tst12: ')@prolog(), X= ${a@main}, p[Y], X = Y, flora_write_goal(X)@prolog(flrdecode), nl@prolog(). -#tst13 :- write('tst13: ')@prolog(), Y= a(), Z=main, X = ${pp[${Y@Z}]}, insert{X}, +#tst13 :- write('tst13: ')@prolog(), Y= a(), Z=main, X = ${pp[${!Y@Z}]}, insert{X}, flora_write_goal(X)@prolog(flrdecode), nl@prolog(). #tst14 :- write('tst14: ')@prolog(), pp[X], flora_write_goal(X)@prolog(flrdecode), nl@prolog(), X = ${a@main}. -#tst15 :- write('tst15: ')@prolog(), Y= a(),Z=main,insert{qq[${Y@Z}]}, +#tst15 :- write('tst15: ')@prolog(), Y= a(),Z=main,insert{qq[${!Y@Z}]}, writeln(' done')@prolog(). #tst16 :- write('tst16: ')@prolog(), qq[X], flora_write_goal(X)@prolog(flrdecode), nl@prolog(), X = ${a@main}. Index: tabletest.flr =================================================================== RCS file: /cvsroot/flora/flora-testsuite/general_tests/tabletest.flr,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- tabletest.flr 7 Sep 2004 22:46:24 -0000 1.5 +++ tabletest.flr 21 Mar 2005 06:52:16 -0000 1.6 @@ -4,7 +4,7 @@ :- table t/0. */ -?- debug[#ignore_undefcheck(${X(Y,Z)})]@flora(sys). +?- debug[#ignore_undefcheck(${!X(Y,Z)})]@flora(sys). // path(X,Y)(Z): a path from X to Y through Z // path(X,Y)(null) means there is an edge from X to Y @@ -39,7 +39,7 @@ // tst3 shows the use of variable functor in the table directive. All // hilog predicates in the form are tabled. // without tabling X/2, it's not going to terminate. -F(X,Y) :- X(F,Y). +!F(X,Y) :- !X(F,Y). p(X,Y) :- q(X,Y). q(a1,b1). |
|
From: Chang Z. <ch...@us...> - 2005-03-21 06:52:28
|
Update of /cvsroot/flora/flora-testsuite/datafiles In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2545/datafiles Modified Files: flImportFloraMod.flr Log Message: introduce variables prefixed with ! for tabled predicates Index: flImportFloraMod.flr =================================================================== RCS file: /cvsroot/flora/flora-testsuite/datafiles/flImportFloraMod.flr,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- flImportFloraMod.flr 2 Feb 2005 12:12:24 -0000 1.8 +++ flImportFloraMod.flr 21 Mar 2005 06:52:15 -0000 1.9 @@ -7,5 +7,5 @@ #addRelationInstance( RelationName,Object1,Object2,StartTime,EndTime) :- - insert{RelationName(Object1,Object2,StartTime,EndTime)}, + insert{!RelationName(Object1,Object2,StartTime,EndTime)}, writeln('Relation instance added')@prolog(). |
|
From: Michael K. <ki...@us...> - 2005-03-20 08:49:14
|
Update of /cvsroot/flora/flora2/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16991 Modified Files: flora2.tex Log Message: clarification about tabled preds that depend on updates Index: flora2.tex =================================================================== RCS file: /cvsroot/flora/flora2/docs/flora2.tex,v retrieving revision 1.123 retrieving revision 1.124 diff -u -d -r1.123 -r1.124 --- flora2.tex 12 Mar 2005 06:01:17 -0000 1.123 +++ flora2.tex 20 Mar 2005 08:49:04 -0000 1.124 @@ -5948,20 +5948,35 @@ was previously inserted into the database. Thus the next query \verb|q(a)| returns with {\tt No}. +\paragraph{Notes on working with backtrackable updates.} Keep in mind that some things that Prolog programmers routinely do with {\tt assert} and {\tt retract} goes against the grain of the use of -backtrackable updates. In particular, {\tt fail}-loops are not going to -work (will leave the database unchanged) for obvious reasons. The {\tt - while} and {\tt until} loops should be used in such situations. - -As before, {\tt btinsertall}, {\tt btdeleteall}, and {\tt bteraseall} -primitives always succeed and leave the free variables unbound. Likewise, -in the all-answers mode, the primitives {\tt btinsert}, {\tt btdelete}, and -{\tt bterase} behave similarly to the {\tt bt*all} versions in other -respects, {\it i.e.}, they will insert or delete facts for every answer to -the associated query. This can be prevented with the use of the cut or the -{\tt flOne} directive. +backtrackable updates. +\begin{itemize} + \item + {\tt fail}-loops are not going to + work (will leave the database unchanged) for obvious reasons. The {\tt + while} and {\tt until} loops should be used in such situations. + \item Tabled predicates or methods must never depend on backtrackable + updates. First, as explained on page~\pageref{page-depchk}, + tabled predicates should not depend on any predicates that have side + effects, because this rarely makes sense. Second, when evaluating + tabled predicates, XSB performs backtracking unbeknownst to the + programmer. Therefore, if a tabled predicate depends on a + backtrackable update, backtracking will happen invisibly, and the + updates will be undone. Therefore, in such situations backtrackable + updates will have no effect. + + \item As before, {\tt btinsertall}, {\tt btdeleteall}, and {\tt + bteraseall} primitives always succeed and leave the free variables + unbound. Likewise, in the all-answers mode, the primitives {\tt + btinsert}, {\tt btdelete}, and {\tt bterase} behave similarly to the + {\tt bt*all} versions in other respects, {\it i.e.}, they will insert + or delete facts for every answer to the associated query. This can be + prevented with the use of the cut or the {\tt flOne} directive. +\end{itemize} +\noindent {\bf Unimplemented}: In the current release, arithmetic expressions in the query part of an update must have their variables be bound by the subgoals that precede the update primitive, except that the literal part does not |
|
From: Michael K. <ki...@us...> - 2005-03-18 18:49:13
|
Update of /cvsroot/flora/flora2/demos In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11603/demos Modified Files: owl_benchmark2_noeq.flr owl_benchmark2_eq.flr Log Message: changed a message Index: owl_benchmark2_noeq.flr =================================================================== RCS file: /cvsroot/flora/flora2/demos/owl_benchmark2_noeq.flr,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- owl_benchmark2_noeq.flr 20 Oct 2004 04:24:55 -0000 1.3 +++ owl_benchmark2_noeq.flr 18 Mar 2005 18:48:59 -0000 1.4 @@ -661,6 +661,6 @@ ** Query *****************************************************************/ -?- (nl, writeln('*** This query takes about 1 min'))@prolog(), +?- (nl, writeln('*** This query takes about 1-2 minutes'))@prolog(), X[owl_equivalentProperty->Y]. Index: owl_benchmark2_eq.flr =================================================================== RCS file: /cvsroot/flora/flora2/demos/owl_benchmark2_eq.flr,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- owl_benchmark2_eq.flr 20 Oct 2004 04:24:55 -0000 1.3 +++ owl_benchmark2_eq.flr 18 Mar 2005 18:49:00 -0000 1.4 @@ -662,6 +662,6 @@ ** Query *******************************************************************/ -?- (nl, writeln('*** This query takes about 1 min'))@prolog(), +?- (nl, writeln('*** This query takes 1-3 minutes'))@prolog(), X[owl_equivalentProperty->Y]. |
|
From: Michael K. <ki...@us...> - 2005-03-18 18:48:34
|
Update of /cvsroot/flora/flora2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11225 Modified Files: flrconfig.P Log Message: make runflora give xsb more initial space Index: flrconfig.P =================================================================== RCS file: /cvsroot/flora/flora2/flrconfig.P,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- flrconfig.P 5 Jan 2005 22:31:50 -0000 1.11 +++ flrconfig.P 18 Mar 2005 18:48:24 -0000 1.12 @@ -15,6 +15,7 @@ from flrporting. ?- path_sysop(expand,'.',FloraDir), + PrologOptions = '-m 100000 -c 20000', % to prevent XSB from crashing xsb_configuration(install_dir,InstallDir), xsb_configuration(config_bindir,ConfigBinDirPrelim), (flora_running_under(windows) @@ -42,7 +43,8 @@ writeln('@echo OFF'), write('@set FLORADIR="'), writeq(FloraDir), write('"'), nl, write('@set PROLOG='), write(ConfigBinDir), writeln('\xsb'), - writeln('@%PROLOG% -e "asserta(library_directory(%FLORADIR%)). [flora2]. flora_shell." %1 %2 %3 %4 %5 %6 %7') + write('@set PROLOGOPTIONS="'), write(PrologOptions), writeln('"'), + writeln('@%PROLOG% %PROLOGOPTIONS% -e "asserta(library_directory(%FLORADIR%)). [flora2]. flora_shell." %1 %2 %3 %4 %5 %6 %7') ; tell('runflora'), writeln('#! /bin/sh'), @@ -53,7 +55,8 @@ nl, write('FLORADIR="'), writeq(FloraDir), write('"'), nl, write('PROLOG='), write(ConfigBinDir), writeln('/xsb'), - writeln('$PROLOG -e "asserta(library_directory($FLORADIR)). [flora2]. flora_shell." $extra_args') + write('PROLOGOPTIONS="'), write(PrologOptions), writeln('"'), + writeln('$PROLOG $PROLOGOPTIONS -e "asserta(library_directory($FLORADIR)). [flora2]. flora_shell." $extra_args') ), told, %% If we are in the packages/flora2 directory and ../../emu exists, then |