{log} - version 4.9.1 


%%%%%%%%%   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}) (or, * {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, h,k integer constants) is the set of  
          integer numbers ranging from h to k (k>=h) or the empty set (h>k)

   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:
       ('t_i' any term, including non-ground intervals)
        - t1 = t2  (equality)
        - t1 neq t2  (non-equality)

   2.  Set/multiset/list constraints:
       ('t', 't_i' any term, including non-ground intervals, 's', 's_i' either a set or 
         a bounded interval, 'sint' either a set of non-negative integers or a bounded 
         interval, 'n' a variable or an integer constant)
        - t1 in t2 (membership)
        - t1 nin t2 (non-membership)
        - inters(t1,t2,t3) (intersection)
        - 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)
        - 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(sint,n) (sum all elements (non-negative integers))
        - smin(sint,n) (minimum element)
        - smax(sint,n) (maximum element)
        - set(t) (t is a set)
        - bag(t) (t is a multiset)
        - list(t) (t is a list)
        - npair(t) (t is not a pair)

   3.  Integer constraints:
       ('e_i' an integer expression, 'n' a variable or an 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)

   4.  Binary relation and partial function constraints:
       ('t' any term, "s", 's_i' either a set or a bounded interval,
         'r', 'r_i' a binary relation, 'f' a partial function)
        - rel(t)/nrel(t) (t is/is_not a binary relation)
        - dom(r,s) (domain)
        - ran(r,s) (range)
        - inv(r,s) (inverse relation)
        - comp(r1,r2,r3) (composition)
        - dres(s,r1,r2) (domain restriction)
        - rres(s,r1,r2) (range restriction)
        - ndres(s,r1,r2) domain anti-restriction)
        - nrres(s,r1,r2) (range anti-restriction)
        - rimg(s1,r,s2) (relational image)
        - oplus(r1,r2,r3) (overriding)
        - pfun(t)/npfun(t)(t is/is_not a partial function)
        - apply(f,t1,t2) (function application)
        - id(s,f) (identity relation)
        - dompf(f,s) (domain of a partial function)
        - comppf(r1,f,r2) (composition of partial functions)

%%%%%%%%% {log} specific built-in predicates %%%%%%%%%

   1.  General:
         -   halt/0: to leave the {log} interactive environment (go back to the 
             host environment)
         -   consult_lib/0: to consult the {log} library file setloglib.slog  
         -   add_lib(F): to add any file F to the {log} library  

   2.  Control predicates:
         -   call(G), call(G,C): to call a {log} goal G, possibly with constraint C  
         -   solve(G): like call(G) but all constraints generated by G are immediately solved 
         -   G!: to make a {log} goal G deterministic

   3.  Monitoring execution:
         -   time(G,T): to get CPU time (in milliseconds) for solving goal G
         -   notrace/0, trace(Mode): to deactivate/activate constraint solving tracing; 
             Mode=sat: general, Mode=irules: inference rules only (default: notrace)

   4.  Constraint solving:
         -   delay(G,C), G, C {log} goals: to delay execution of G     
             until either C holds or the computation ends; 
         -   delay(irreducible(G),C), G, C {log} goals: to delay execution of G 
             until C holds; otherwise return irreducible(G)
         -   nolabel/0, label/0: to deactivate/activate the global FD labeling
             (default: label)
         -   labeling(X): to force labeling for the domain variable X
         -   strategy(S): to change goal atom selection strategy to S
             (S: cfirst, ordered, cfirst(list_of_atoms))
         -   noneq_elim/0, neq_elim/0: to deactivate/activate elimination of neq 
             constraints (default: neq_elim)
         -   noirules/0, irules/0: to deactivate/activate inference rules 
             (default: irules)

%%%%%%%% {log} help %%%%%%%%

         -   help/0: to get general help information about {log}
         -   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

%%%%%%%% Using Prolog from {log} %%%%%%%%

   1.  General
         -   prolog_call(G): to call any Prolog goal G from {log}

   2.  Prolog-like built-in predicates directly available in {log}
         -   abolish/0
         -   assert/1
         -   arg/3
         -   call/1
         -   consult/1
         -   functor/3
         -   ground/1
         -   listing/0
         -   name/2
         -   nl/0
         -   nonvar/1
         -   read/1
         -   var/1
         -   write/1
         -   =../2
         -   ==/2
         -   \==/2
         -   @/2
         -   @==/2


%%%%%%%% Prolog predicates for accessing {log} facilities %%%%%%%%%

   -   setlog_consult(F): to consult a {log} file F
   -   consult_lib: to consult the {log} library file

   -   setlog/0: to enter/re-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_clause(Cl): to add a {log} clause Cl to the current {log} program
   -   setlog_config(list_of_params): to modify {log} configuration parameters
       (parameters: strategy(S), path(Path), rw_rules(File))
   -   setlog_rw_rules: to load the filtering rule library


%%%%%%%% {log} library predicates (file 'setloglib.slog') %%%%%%%%

   Dealing with sets
   -   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
   -   int_to_set(+I,?S): S is the set of all elements of the interval I
   -   dint_to_set(A,B,S): like int_to_set/2 but delayed if interval bounds are unknown
   -   diff1(?S,?X,?R): equivalent to diff(S,{X},R) but more efficient
   -   eq(?T1,?T2): syntactic unification between terms T2 and T2
   -   bun(?S,?R): generalized union: R is the union of all elements of the set of sets S
   -   binters(S,R): generalized intersection: R is the inersection of all elements of the set of sets S
   
   Dealing with multisets 
   -   int_to_bag(+I,?M): M is the multiset of all elements of the interval I
   -   bag_to_set(+M,?S): S is the set of all elements of the bag M
   -   msize(?S,?N): multiset cardinality (N = |S|)

   Dealing with lists 
   -   prefix(P,L): list P is a prefix of list L
   -   sublist(Sb,L): list Sb is a sublist of list L
   -   take(+N,L,NewL): list NewL consists of the first N elements of list L
   -   drop(+N,L,NewL): NewL is L with its first N elements removed
   -   extract(S,L,NewL): S is a set of integer numbers, L is a list of elements of any type, 
       and NewL is a list containing the i-th element of L, for all i in S
       (e.g., extract({4,2},[a,h,g,m,t,r],L) ==> L = [h,m])
   -   filter(L,S,NewL): L is a list, S is a set, and NewL is a list containing the elements 
       of L that are also elements of S
       (e.g., filter([a,h,g,m,t,r],{m,h,s},L) ==> L = [h,m])

   Redefining Prolog built-ins (for the user convenience)
   -   member(X,L) 
   -   append(L1,L2,L3) 
   -   nth1(X,L,Y) 
   -   length(L,N) 
   -   reverse(L,R) 
   -   last(L,X) 

   Improved {log} set constraints, allowing intervals with
   unknown bounds - user-defined predicates

   -   T ein S (membership): same as T in S
   -   T enin S (not membership): same as T nin S
   -   einters(S1,S2,S3) (intersection): same as inters(S1,S2,S3)
   -   esubset(S1,S2) (inclusion): same as subset(S1,S2), but allowing
                                   S1, S2 to be either a set or an unbouded interval
   -   essubset(S1,S2) (strict inclusion):  same as ssubset(S1,S2), but allowing
                                   S1, S2 to be either a set or an unbouded interval

   Labeling predicates for unbounded domains

   -   label(nat,X): to generate all natural numbers: 0,1,2,...
   -   label(int,X): to generate all integer numbers: 0,1,-1,2,-2,... 
   -   label(list,L): to generate all lists of increasing length (starting from [])
   -   label(set,L): to generate all sets of increasing cardinality (starting from {})