%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Predicate Library %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Predicate: write_list(+List). % Writes out each element of List on the screen, throwing a newline % between elements. % Control mechanism: simple recursion % I/O builtins: write/1, nl/0 % e.g. | ?- write_list([foo(a), 'Hello', baz]). % foo(a) % Hello % baz write_list([Head|Tail]):- write(Head), nl, write_list(Tail). write_list([]). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % A modification of write list report_error([]) :- nl. report_error([X|L]) :- write(X), write(' '), report_error(L). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % ancestor( (Ent, ID), (Ent1, ID1) ) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ancestor(Child, Parent) :- Child = (Entity, ID), dyn(ent_occ(Entity, ID, Parents)), % child exists Parent = (Entity1, ID1), member((Entity1, ID1), Parents). % Parent is the parent ancestor(Child, Parent) :- Child = (Entity, ID), dyn(ent_occ(Entity, ID, Parents)), % child exists Parent = (Entity1, ID1), \+ member((Entity1, ID1), Parents), % Parent is NOT the parent member((Entity2, ID2), Parents), % Parent2 is the parent ancestor((Entity2, ID2), Parent ). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set([], []). set([X|L], [X|Res] ) :- \+ member(X, L), set(L, Res). set([X|L], Res ) :- member(X, L), set(L, Res). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% member(X, [X|_]). member(X, [_|L]) :- member(X, L). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % delete(+Ele, +List, -Rest_list) % only delete the first X element from the list deleteX(_, [], []). deleteX(X, [X|L], L). deleteX(X, [O|L], [O|Res]) :- \+ X = O, deleteX(X, L, Res). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% append(L, [], L). append([], L, L). append([X|L1], L, [X|Result]) :- append(L1, L, Result). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % Small is a subset of Large subset(Small, Large) :- findall(_,( member(X, Small), member(X, Large)), _). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% pretty_print(Term) :- Term =.. List, pretty(List). pretty([]). pretty([X|R]) :- write(X),nl, pretty(R). %%%%%%%%%%%%%%% end of document %%%%%%%%%%%%%%%%%%%%%% tt, New) )). exec_postcondition(Process, PID, Occ, [notexists, old_attribute_value] ) :- dyn(change(_, _, Del, _)), Del = [dyn(trigger(_, Process, PID, List))], member(change_normal_entity(Att, Old, _New), List), \+ dyn(ent_occ_att(Occ, (Att, Old) )). % Inclusion of change normal entity to process scope exec_postcondition(Process, PID, Occ, [exists,occ_change_normal_entity]) :- dyn(occ_change_normal(Process, PID, Occ)). %--------------------------------------------------------- % Library Predicates %--------------------------------------------------------- % exists(+List) % All elements in the List exists in the working memory. % Or all facts are true included in the List. exists([]). exists([X|L]) :- X, exists(L). member(X, [X|_]). member(X, [_|L]) :- member(X, L). % delete(+Ele, +List, -Rest_list) % only delete one element from the list deleteX(_, [], []). deleteX(X, [X|L], L). deleteX(X, [O|L], [O|Res]) :- \+ X = O, deleteX(X, L, Res). %--------------- End of Document ------------------------