794f7d1ce7
Next we plan to support other bluitins through eam and-or-tree controls. Example: var(X) must be transformed into wait_till_bound(X), var(X) that will fail if X is bound or waits till is leftmost in the and-or-tree before continuning... git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@1588 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
42 lines
2.2 KiB
Prolog
42 lines
2.2 KiB
Prolog
/*************************************************************************
|
|
* *
|
|
* YAP Prolog *
|
|
* *
|
|
* Yap Prolog was developed at NCCUP - Universidade do Porto *
|
|
* BEAM extends the YAP Prolog system to support the EAM *
|
|
* *
|
|
* Copyright Ricardo Lopes and Universidade do Porto 2000-2006 *
|
|
* *
|
|
**************************************************************************
|
|
* *
|
|
* File: eam.yap *
|
|
* Last rev: 6/4/2006 *
|
|
* mods: *
|
|
* comments: Some utility predicates needed by BEAM *
|
|
* *
|
|
*************************************************************************/
|
|
|
|
eamtrans(A,A):- var(A),!.
|
|
eamtrans((A,B),(C,D)):- !, eamtrans(A,C),eamtrans(B,D).
|
|
eamtrans((X is Y) ,(skip_while_var(Vars), X is Y )):- !, '$variables_in_term'(Y,[],Vars).
|
|
eamtrans((X =\= Y),(skip_while_var(Vars), X =\= Y )):- !, '$variables_in_term'(X + Y,[],Vars).
|
|
eamtrans((X =:= Y),(skip_while_var(Vars), X =:= Y )):- !, '$variables_in_term'(X + Y,[],Vars).
|
|
eamtrans((X >= Y) ,(skip_while_var(Vars), X >= Y )):- !, '$variables_in_term'(X + Y,[],Vars).
|
|
eamtrans((X > Y) ,(skip_while_var(Vars), X > Y )):- !, '$variables_in_term'(X + Y,[],Vars).
|
|
eamtrans((X < Y) ,(skip_while_var(Vars), X < Y )):- !, '$variables_in_term'(X + Y,[],Vars).
|
|
eamtrans((X =< Y) ,(skip_while_var(Vars), X =< Y )):- !, '$variables_in_term'(X + Y,[],Vars).
|
|
eamtrans((X @>= Y) ,(skip_while_var(Vars), X @>= Y )):- !, '$variables_in_term'(X + Y,[],Vars).
|
|
eamtrans((X @> Y) ,(skip_while_var(Vars), X @> Y )):- !, '$variables_in_term'(X + Y,[],Vars).
|
|
eamtrans((X @< Y) ,(skip_while_var(Vars), X @< Y )):- !, '$variables_in_term'(X + Y,[],Vars).
|
|
eamtrans((X @=< Y) ,(skip_while_var(Vars), X @=< Y )):- !, '$variables_in_term'(X + Y,[],Vars).
|
|
|
|
eamtrans((X \= Y) ,(skip_while_var(Vars), X \= Y )):- !, '$variables_in_term'(X + Y,[],Vars).
|
|
eamtrans((X \== Y),(skip_while_var(Vars), X \== Y )):- !, '$variables_in_term'(X + Y,[],Vars).
|
|
|
|
eamtrans(B,B).
|
|
|
|
eamconsult(File):- eam, eam, %fails if eam is disable
|
|
assert((user:term_expansion((A :- B),(A :- C)):- eamtrans(B,C))),
|
|
eam, ( consult(File) ; true), eam,
|
|
abolish(user:term_expansion,2).
|