{log} - version 4.6.14 %%%%%%%%% Syntactic conventions %%%%%%%%% 1. Extensional set/multiset terms: - {a,b,c} is a set containing three elements, a, b, c (equivalent to {} with c with b with a) - {a,b\R} is the set {a,b} U R (equivalent to R with b with a) - *{a,b,b} is a multiset containing the elements, 'a' (1 occurrence) and 'b' (2 occurrences) (equivalent to {} mwith c mwith b mwith a) - *{a,b\R} is the multiset *{a,b} U R (equivalent to R mwith b mwith a) - {} is the empty set/multiset - int(h,k) (interval) is the set of integer numbers ranging from h to k (h,k integer constants) 2. RUQs: ('a' either a set or a multiset or a list or an interval int(h,k)) - forall(X in a, G), X variable and G any {log} goal containing X - forall(X in a, exists(V,G)), - forall(X in a, exists([V1,...,Vn],G)), V1,...,Vn variables local to G 3. Intensional set terms: - {X : G}, X variable and G any {log} goal containing X - {X : exists(V,G)}, V variable local to G - {X : exists([V1,...,Vn],G)}, V1,...,Vn variables local to G 4. Syntactic differences w.r.t. std Prolog: - & is used in place of , in clause bodies - or is used in place of ; to represent goal disjunction. - neg or naf are used in place of \+ to represent negation (resp., simplified Constructive Negation and Negation as Failure) %%%%%%%%% {log} constraints %%%%%%%%% 1. General constraints: ('t1', 't2' any term) - t1 = t2 (equality) - t1 neq t2 (non-equality) 2. Set/multiset/list constraints: ('t' any term, 's' either a set or an interval, 'a' any aggregate (set, interval, multiset, list) - t in a (membership) - t nin a (non-membership) - un(s1,s2,s3) (union) - nun(s1,s2,s3) (non-union) - disj(s1,s2) (disjointness) - ndisj(s1,s2) (non-disjointness) - less(s1,t,s3) (element removal) - subset(s1,s2) (subset) - nsubset(s1,s2,s3) (not subset) - ssubset(s1,s2) (strict subset) - inters(s1,s2,s3) (intersection) - ninters(s1,s2,s3) (not intersection) - diff(s1,s2,s3) (difference) - ndiff(s1,s2,s3) (not difference) - sdiff(s1,s2,s3) (symmetric difference) - size(s,n) (cardinality) - sum(s,n) (sum all elements (non-negative integers)) - set(s) (s is a set) - bag(t) (t is a multiset) - list(t) (t is a list) 3. Integer constraints: (e1, e2 integer expressions, n variable or integer constant) - n is e1 (equality - with evaluation of expression e) - e1 =< e2 (less or equal), e1 < e2 (less) - e1 >= e2 (greater or equal), e1 > e2 (greater) - e1 =:= e2 (equal), e1 =\= e2 (not equal) - integer(n) (n is an integer number) - ninteger(n) (n is not an integer number) %%%%%%%%% {log} specific built-in predicates %%%%%%%%% - halt/0: to leave the {log} interactive environment (go back to the host environment) - help/0: to get general help information about {log} - prolog_call/1: to call any Prolog goal from {log} - consult_lib/0: to consult the {log} library file - !/1 (used postfix): G!, G any {log} goal: makes G deterministic - delay(G,C), G, C any {log} goals: delays execution of G until C holds - nolabel/0, label/0: to deactivate/reactivate the automatic FD labeling function - labeling(X): to force labeling for a domain variable X - trace/0, notrace/0: to activate/deactivate constraint solving tracing %%%%%%%% Prolog-like built-in predicates %%%%%%%% - nl/0 - ground/1 - var/1 - nonvar/1 - name/2 - functor/3 - arg/3 - =../2 - ==/2 - \==/2 - @/2 - @==/2 - read/1 - write/1 - call/1 - assert/1 - consult/1 - listing/0 - abolish/0 {log} library predicates not available Type consult_lib to load the {log} library %%%%%%%% {log} library predicates %%%%%%%% - powerset(+S,?PS): powerset (PS = 2^S) - cross_product(+A,+B,?CP): the Cartesian product of sets A and B - list_to_set(+L,?S): S is the set of all elements of the list L - bag_to_set(+M,?S): S is the set of all elements of the bag M - int_to_set(+I,?S): S is the set of all elements of the interval I - int_to_bag(+I,?M): M is the multiset of all elements of the interval I - diff1(?S,?X,?R): equivalent to diff(S,{X},R) but more efficient - msize(?S,?N): multiset cardinality (N = |S|) The {log} library provides also alternative definitions for some set predicates, aimed at reducing the number of repeated solutions - xless/3 - xsubset/2 - xun/3 - xint/3 - xdiff/3 - xndiff/3 - xsdiff/3 - xsize/2 %%%%%%%% {log}=> help %%%%%%%% - h(syntax), h(constraint), h(built), h(lib), h(prolog) to get help information (resp., about: {log} syntactic convenctions, {log} constraints, {log} built-in predicates, {log} library predicates, Prolog predicates for accessing {log}) - h(all) to get all available help information - setlog/0: to enter the {log} interactive environment - setlog(G), setlog(G,C): to call a {log} goal G, possibly getting an (output) {log} constraint C - setlog(G,InCLst,OutCLst), setlog_partial(G,InCLst,OutCLst), setlog_sc(C,InCLst,OutCLst): to solve a {log} goal G / constraint C with a (possibly empty) input constraint list InCLst and output constraint list OutCLst %%%%%%%% Prolog predicates for accessing {log} facilities %%%%%%%%% - setlog/0: to enter the {log} interactive environment - setlog(G), setlog(G,C): to call a {log} goal G, possibly getting an (output) {log} constraint C - setlog(G,InCLst,OutCLst), setlog_partial(G,InCLst,OutCLst), setlog_sc(C,InCLst,OutCLst): to solve a {log} goal G / constraint C with a (possibly empty) input constraint list InCLst and output constraint list OutCLst - setlog_consult(F): to consult a {log} file F - consult_lib: to consult the {log} library file - setlog_clause(Cl): to add a {log} clause Cl to the current {log} program