{log} - version 4.5 Syntax 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 2. 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. 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 5. 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) Predefined constraints 1. General: ('t1', 't2' any term, including set, multiset, and list terms)) - t1 = t2 (equality) - t1 neq t2 (non-equality) 2. Set/multiset/list constraints: ('t' any term, 's' a set, 'a' either a set or a multiset or a list) - t in a (membership) - t in int(h,k) (interval membership) int(h,k) is the set of integer numbers ranging from h to k (h,k integer constants) - 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) - int(s1,s2,s3) (intersection) - nint(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) - set(t) (t 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; compare values returned by the evaluation of 'e1' and 'e2') - n is e1 (equal) - e1 =< e2 (less or equal), e1 < e2 (less) - e1 >= e2 (greater or equal), e1 > e2 (greater) - e1 =:= e2 (equal), e1 =\= e2 (not equal) - integer(t) (t is an integer number) {log} specific built-in predicates - help/0, help(built), help(lib), help(prolog) to get help information (resp., general, about {log} built-in predicates, about {log} library predicates, about Prolog predicates for accessing {log}) - halt/0 to leave {log} (go back to the Prolog environment) - prolog_call/1 to call any Prolog goal from the {log} environment - !/1 (used postfix): G!, G any {log} goal: makes G deterministic - delay(G,C), G, C any {log} goal: delays execution of G until C holds. Prolog-like {log} built-in predicates - read/1 - write/1 - call/1 - assert/0, assert/1 - consult/0, consult/1 - listing/0 - abolish/0 {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 Prolog predicates for accessing {log} facilities - setlog_call(G), setlog_call(G,C): to call a {log} goal G, possibly getting an (output) {log} constraint C - setlog_consult(F): to consult any {log} file F - setlog_clause(Cl): to add a {log} clause Cl to the current {log} program - setlog_help/0, h/0: to get general help information about {log} - setlog/0, setlog_start/0: to (re-)enter the {log} interactive environment