From 0afa88bd187747a37442be10c916f819cc20dacf Mon Sep 17 00:00:00 2001
From: Allan Blanchard <allan.blanchard@cea.fr>
Date: Fri, 17 Jun 2022 18:26:00 +0200
Subject: [PATCH] OCP-Indent + fix-syntax

---
 meta_annotate.ml      |   42 +-
 meta_bindings.ml      |    8 +-
 meta_deduce.ml        |   62 +-
 meta_dispatch.ml      |    2 +-
 meta_dispatch.mli     |    2 +-
 meta_parse.ml         |    4 +-
 meta_simplify.ml      |   10 +-
 meta_utils.ml         |    1 -
 proofs/meta_model.why |    2 +-
 share/model.slog      |    8 +-
 share/setlog.pl       | 3118 ++++++++++++++++++++---------------------
 share/setlog_rules.pl |   52 +-
 12 files changed, 1655 insertions(+), 1656 deletions(-)

diff --git a/meta_annotate.ml b/meta_annotate.ml
index 0c88324..b5a2c31 100644
--- a/meta_annotate.ml
+++ b/meta_annotate.ml
@@ -167,17 +167,17 @@ let get_callsites_ips kf rips =
        do not set up a proxy over a vacuous set of properties. *)
     | [] -> []
     | _ ->
-        let segmented =
-          List.map
-            (fun rip ->
-              Statuses_by_call.setup_precondition_proxy kf rip;
-              List.map
-                (fun (_, stmt) ->
+      let segmented =
+        List.map
+          (fun rip ->
+             Statuses_by_call.setup_precondition_proxy kf rip;
+             List.map
+               (fun (_, stmt) ->
                   Statuses_by_call.precondition_at_call kf rip stmt)
-                calls)
-            rips
-        in
-        List.concat segmented
+               calls)
+          rips
+      in
+      List.concat segmented
 
 (* Simply modifies a function contract to ensures that pred is a weak invariant *)
 class weak_inv_visitor flags full_table table (pre, post) = object (self)
@@ -320,8 +320,8 @@ let inspect_contract process stmt ckf args =
       match b.b_assigns with
         | WritesAny ->
           Self.warning "Cannot analyze footprint of function %a: no assigns \
-          clause. Assuming meta-properties with reading/writing contexts are \
-          valid in this function." Kernel_function.pretty ckf
+                        clause. Assuming meta-properties with reading/writing contexts are \
+                        valid in this function." Kernel_function.pretty ckf
         | Writes l -> process ckf stmt vis l ass
     ) ckf
 
@@ -417,17 +417,17 @@ class reading_visitor flags all_mp table = object (self)
     in_exp <- true ;
     match e.enode with
       | SizeOfE _ | AlignOfE _ ->
-          (* we're not evaluating the expression itself, merely its type. *)
-          in_exp <- false; Cil.SkipChildren
+        (* we're not evaluating the expression itself, merely its type. *)
+        in_exp <- false; Cil.SkipChildren
       | AddrOf (_,o) | StartOf(_,o) ->
-          (* the toplevel lval is not read. However, we might read some lvals
-             when evaluating the offset. The host is always a Var in this
-             context, thus we don't need to visit it further. *)
-          ignore (Visitor.visitFramacOffset (self:>Visitor.frama_c_visitor) o);
-          in_exp <- false;
-          Cil.SkipChildren
+        (* the toplevel lval is not read. However, we might read some lvals
+           when evaluating the offset. The host is always a Var in this
+           context, thus we don't need to visit it further. *)
+        ignore (Visitor.visitFramacOffset (self:>Visitor.frama_c_visitor) o);
+        in_exp <- false;
+        Cil.SkipChildren
       | _ ->
-          Cil.DoChildrenPost (fun e -> in_exp <- false ; e)
+        Cil.DoChildrenPost (fun e -> in_exp <- false ; e)
 
   (* When encoutering an lval in an expression, add it to the statement set *)
   method! vlval lval =
diff --git a/meta_bindings.ml b/meta_bindings.ml
index 9896a7b..c115c6d 100644
--- a/meta_bindings.ml
+++ b/meta_bindings.ml
@@ -150,10 +150,10 @@ let add_ghost_code flags =
         let rec aux = function
           | [] -> []
           | s :: t ->
-              let aux_stmt = find_hash_list Stmt_Hashtbl.find_opt to_add s in
-              if aux_stmt <> [] then
-                mark_changed (Option.get self#current_func);
-              aux_stmt @ [s] @ (aux t)
+            let aux_stmt = find_hash_list Stmt_Hashtbl.find_opt to_add s in
+            if aux_stmt <> [] then
+              mark_changed (Option.get self#current_func);
+            aux_stmt @ [s] @ (aux t)
         in block.bstmts <- aux block.bstmts;
         block
       )
diff --git a/meta_deduce.ml b/meta_deduce.ml
index 3d5e1e1..d0250a6 100644
--- a/meta_deduce.ml
+++ b/meta_deduce.ml
@@ -34,7 +34,7 @@ let emitter = Emitter.create "Deduction engine"
 (** ==== PRINTERS FOR THE GENERATION OF PROLOG MODELS ==== *)
 
 (** Print variables as their name and unique id *)
-let pp_vi fmt vi = 
+let pp_vi fmt vi =
   Format.fprintf fmt "%s_%d" (String.lowercase_ascii vi.vname) vi.vid
 
 (** Handle offset when printing variables *)
@@ -86,7 +86,7 @@ let get_vi_name func acc =
 
 (** Expand set formula defining the targets of an HILARE.
     In particular, resolve \ALL, \callers, \callees, \in_file
-    and perform set operations 
+    and perform set operations
 *)
 let rec compute_target = function
   | TgAll ->
@@ -145,14 +145,14 @@ let generate_callgraph fmt targets =
 
 (** Generic printer for lists *)
 let print_setlist pp =
-    let open Format in
-    let pp_sep fmt () = pp_print_string fmt ", " in
-    pp_print_list ~pp_sep pp
+  let open Format in
+  let pp_sep fmt () = pp_print_string fmt ", " in
+  pp_print_list ~pp_sep pp
 
 (** Generic printer for sets of strings *)
 let print_set pp fmt s =
-    StrSet.fold (fun x l -> x :: l) s []
-    |> print_setlist pp fmt
+  StrSet.fold (fun x l -> x :: l) s []
+  |> print_setlist pp fmt
 
 
 (** In order to get the predicate of an HILARE, we must type it.
@@ -199,7 +199,7 @@ let identify_pred mp preds globals =
       incr predicate_counter;
       let fp = compute_footprint unpacked globals in
       let print fmt () =
-          Format.fprintf fmt "property({%a},%s)"
+        Format.fprintf fmt "property({%a},%s)"
           (print_setlist pp_vi) fp
           pname
       in
@@ -228,7 +228,7 @@ let is_not_written_predicate globals mp =
     | Pseparated [d; l] when Logic_utils.is_same_term d dt ->
       begin match l.term_node with
         | TAddrOf tlval ->
-                get_global_variable globals tlval
+          get_global_variable globals tlval
         | _ -> None
       end
     | _ -> None
@@ -257,21 +257,21 @@ let is_negative_assigns_predicate globals mp =
 (** Export a predicate, trying to match against known patterns *)
 let pp_property preds globals mp =
   let default () =
-      let print, preds = identify_pred mp preds globals in
-      print, preds
+    let print, preds = identify_pred mp preds globals in
+    print, preds
   in
   begin match mp.mp_context with
     | Postcond ->
       begin match is_negative_assigns_predicate globals mp with
         | Some vi_off ->
-            (fun fmt () ->
-                Format.fprintf fmt "negative_assigns(%a)" pp_vi_off vi_off), preds
+          (fun fmt () ->
+             Format.fprintf fmt "negative_assigns(%a)" pp_vi_off vi_off), preds
         | None -> default ()
       end
     | Writing ->
       begin match is_not_written_predicate globals mp with
-        | Some vi_off -> 
-                (fun fmt () -> Format.fprintf fmt "not_written(%a)" pp_vi_off vi_off), preds
+        | Some vi_off ->
+          (fun fmt () -> Format.fprintf fmt "not_written(%a)" pp_vi_off vi_off), preds
         | None -> default ()
       end
     | _ -> default ()
@@ -279,22 +279,22 @@ let pp_property preds globals mp =
 
 (** Export a whole HILARE: context (as a string), predicate, target set *)
 let generate_mp prefix preds globals fmt (mp, tset) =
-    let print, preds = pp_property preds globals mp in
-    Format.fprintf fmt "%% Export of HILARE %s@.meta_%s(\"%s\", %a, {%a}).@."
+  let print, preds = pp_property preds globals mp in
+  Format.fprintf fmt "%% Export of HILARE %s@.meta_%s(\"%s\", %a, {%a}).@."
     mp.mp_name prefix
     (match mp.mp_context with
-        | Weak_invariant -> "Weak invariant"
-        | Strong_invariant -> "Strong invariant"
-        | Conditional_invariant -> "Conditional invariant"
-        | Postcond -> "Postcond"
-        | Precond -> "Precond"
-        | Writing -> "Writing"
-        | Reading -> "Reading"
-        | Calling -> "Calling"
+      | Weak_invariant -> "Weak invariant"
+      | Strong_invariant -> "Strong invariant"
+      | Conditional_invariant -> "Conditional invariant"
+      | Postcond -> "Postcond"
+      | Precond -> "Precond"
+      | Writing -> "Writing"
+      | Reading -> "Reading"
+      | Calling -> "Calling"
     )
     print ()
     (print_set pp_ta) tset;
-    preds
+  preds
 
 (** Export all previous HILARE *)
 let all_preds = ref None
@@ -303,7 +303,7 @@ let generate_mps fmt (mps, globals, tsets) =
     | [] -> all_preds := Some preds
     | mp :: t ->
       let preds = generate_mp "ground" preds globals fmt (mp,
-         (List.assoc mp.mp_name tsets))
+                                                          (List.assoc mp.mp_name tsets))
       in aux preds t
   in aux [] mps
 
@@ -339,10 +339,10 @@ let deduce flags mp ip mps =
   in
 
   let print_goal fmt () =
-      match !all_preds with
+    match !all_preds with
       | Some p ->
-      ignore (generate_mp "valid" p globals fmt
-      (mp, compute_target mp.mp_target))
+        ignore (generate_mp "valid" p globals fmt
+                  (mp, compute_target mp.mp_target))
       | None -> failwith "Oh no"
   in
 
@@ -377,7 +377,7 @@ go :- %a
   close_out oc;
   (* Locate where the Prolog model is and go to it *)
   let sharedir = Format.asprintf "%a"
-    Filepath.Normalized.pp_abs (Self.Share.get_dir ".") in
+      Filepath.Normalized.pp_abs (Self.Share.get_dir ".") in
   Sys.chdir sharedir;
   (* Run the Prolog model on our file, with a 30s timeout *)
   let command = Format.asprintf "./run.pl prove %s 30 > /dev/null" filename in
diff --git a/meta_dispatch.ml b/meta_dispatch.ml
index 38150bd..0008eda 100644
--- a/meta_dispatch.ml
+++ b/meta_dispatch.ml
@@ -91,7 +91,7 @@ let unpack_mp flags mp admit =
   {ump_emitter; ump_property; ump_ip; ump_counter; ump_admit = admit; ump_assert}
 
 (* Returns an assoc list associating each context to a
- * hash table mapping each function to a list of 
+ * hash table mapping each function to a list of
  * MP names to process for that context and for that function.
  * The order is the same as in the original file
  *
diff --git a/meta_dispatch.mli b/meta_dispatch.mli
index 5f510ff..66889f3 100644
--- a/meta_dispatch.mli
+++ b/meta_dispatch.mli
@@ -36,7 +36,7 @@ type unpacked_metaproperty = {
 
 val dispatch : meta_flags ->
   metaproperty list ->
-  (context * string list Str_Hashtbl.t) list * 
+  (context * string list Str_Hashtbl.t) list *
   (string, unpacked_metaproperty) Hashtbl.t
 
 val name_mp_pred : meta_flags ->
diff --git a/meta_parse.ml b/meta_parse.ml
index a09f9a8..5b41483 100644
--- a/meta_parse.ml
+++ b/meta_parse.ml
@@ -140,7 +140,7 @@ let meta_type_term termassoc quantifiers kf loc orig_ctxt meta_ctxt env expr =
       Logic_const.tat (e_t, label)
     | PLapp ("\\formal", _, [{lexpr_node = PLvar param}]) ->
       let formals = Kernel_function.get_formals kf in
-      begin try 
+      begin try
         let vi = List.find (fun vi -> vi.vname = param) formals in
         let lv = Cil.cvar_to_lvar vi in
         Logic_const.tvar lv
@@ -168,7 +168,7 @@ let meta_type_term termassoc quantifiers kf loc orig_ctxt meta_ctxt env expr =
       begin match List.assoc_opt vname termassoc with
         | Some RepVariable a -> a
         | None -> meta_ctxt.error loc
-                  "Variable %s forbidden in this context" vname
+                    "Variable %s forbidden in this context" vname
         | _ -> meta_ctxt.error loc
                  "%s expects one argument but has been provided with none" vname
       end
diff --git a/meta_simplify.ml b/meta_simplify.ml
index 7b1acfa..af70c79 100644
--- a/meta_simplify.ml
+++ b/meta_simplify.ml
@@ -36,7 +36,7 @@ let is_not_orig_variable lv =
     | None -> true
 
 (*
- * Returns true if two tlvals are obviously \separated 
+ * Returns true if two tlvals are obviously \separated
  * That is, if they are both named variables with different names or with non-overlapping
  * offsets
  *)
@@ -68,12 +68,12 @@ let neq_lval tl1 tl2 =
   match (h1, h2) with
     | TVar lv, _ when is_not_orig_variable lv -> true
     | _, TVar lv when is_not_orig_variable lv -> true
-    | TVar l1, TVar l2 -> 
+    | TVar l1, TVar l2 ->
       not (Logic_utils.is_same_var l1 l2) || offset_neq of1 of2
     | _ -> false
 
-(* 
-   Assuming t is a term representing an address, 
+(*
+   Assuming t is a term representing an address,
    returns the lval it is an address of
 *)
 let get_addressed_lval t = match t.term_node with
@@ -90,7 +90,7 @@ let get_addressed_var_opt t = match t.term_node with
   | TStartOf l -> Some l
   | _ -> None
 
-(* 
+(*
  * Simplifies \separated predicates to \true or \false when possible, and
  * propagates through common logic operators. Also simplifies equality and
  * difference when terms are the same
diff --git a/meta_utils.ml b/meta_utils.ml
index ffbfd14..01a2cb0 100644
--- a/meta_utils.ml
+++ b/meta_utils.ml
@@ -35,4 +35,3 @@ let find_hash_list find_opt table key =
 let add_to_hash_list (find_opt, replace) table key v =
   let old_list = find_hash_list find_opt table key in
   replace table key (v :: old_list)
-
diff --git a/proofs/meta_model.why b/proofs/meta_model.why
index 1d38fdd..1e87a44 100644
--- a/proofs/meta_model.why
+++ b/proofs/meta_model.why
@@ -123,7 +123,7 @@ module Meta_Lemmas
         forall prog: program.
         valid_program prog ->
         forall fn: function_name. exists f. M.mapsto fn f prog
-        
+
      lemma all_calls_valid_choose:
         forall prog, f: function_name.
         valid_program prog ->
diff --git a/share/model.slog b/share/model.slog
index 8d2339c..8d6b19b 100644
--- a/share/model.slog
+++ b/share/model.slog
@@ -41,7 +41,7 @@ reaches(X, Y, A) :-
 % 1-step callees of functions in S
 callees(S, Callees) :-
     Callees = {To :
-        exists(From, 
+        exists(From,
             From in S &
             calls(From, To)
         )
@@ -102,13 +102,13 @@ propag_check(_, _, "Strong invariant").
 % ------------------
 
 % Avoid long matching time using double negation
-fast_meta_ground(C, P, S) :- 
+fast_meta_ground(C, P, S) :-
     var(S) &
     meta_ground(C, P, S).
 
-fast_meta_ground(C, P, S) :- 
+fast_meta_ground(C, P, S) :-
     nonvar(S) &
-    meta_ground(C, P, D) &  
+    meta_ground(C, P, D) &
     naf (S neq D).
 
 % -------------------
diff --git a/share/setlog.pl b/share/setlog.pl
index 1a610a1..7bcbcb0 100644
--- a/share/setlog.pl
+++ b/share/setlog.pl
@@ -12,25 +12,25 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  VERSION 4.9.1-20
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%                                                          
-%%                The {log} interpreter and solver                  
-%%                                                           
-%%                           VERSION 4.9.1   
-%%                                             
-%%                      original development by                                                          
-%%                Agostino Dovier     Eugenio Omodeo          
-%%                Enrico Pontelli     Gianfranco Rossi  
+%%
+%%                The {log} interpreter and solver
+%%
+%%                           VERSION 4.9.1
+%%
+%%                      original development by
+%%                Agostino Dovier     Eugenio Omodeo
+%%                Enrico Pontelli     Gianfranco Rossi
 %%
 %%                    subsequent enhancements by
 %%                         Gianfranco Rossi
 %%
-%%                    with the contribution of 
+%%                    with the contribution of
 %%       B.Bazzan  S.Manzoli  S.Monica  C.Piazza  L.Gelsomino
 %%
-%%                        Last revision by 
+%%                        Last revision by
 %%               Gianfranco Rossi and Maximiliano Cristia'
-%%                         (April 2016)           
-%%                                                              
+%%                         (April 2016)
+%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 
@@ -40,9 +40,9 @@
              op(950,xfy,&),
              op(900,fy,[neg,naf]),
              op(800,xf,!),
-             op(700,xfx,[in,neq,nin]), 
-             op(670,xfx,\),                    
-             op(650,yfx,[with,mwith]), 
+             op(700,xfx,[in,neq,nin]),
+             op(670,xfx,\),
+             op(650,yfx,[with,mwith]),
              op(150,fx,*),
              setlog/0,           % for interactive use
              setlog/1,           % to call setlog from Prolog
@@ -53,19 +53,19 @@
              setlog_consult/1,
              consult_lib/0,
              setlog_clause/1,
-             setlog_config/1, 
-             setlog_clear/0,   
-             setlog_rw_rules/0,  
-             setlog_help/0,           
-             h/1 
+             setlog_config/1,
+             setlog_clear/0,
+             setlog_rw_rules/0,
+             setlog_help/0,
+             h/1
    ]).
 
-:- use_module(library(clpfd)). 
-:- use_module(library(dialect/sicstus/timeout)).         
+:- use_module(library(clpfd)).
+:- use_module(library(dialect/sicstus/timeout)).
 
-:- dynamic isetlog/2.                                  
-:- dynamic newpred_counter/1. 
-:- dynamic context/1. 
+:- dynamic isetlog/2.
+:- dynamic newpred_counter/1.
+:- dynamic context/1.
 :- dynamic final/0.
 :- dynamic nowarning/0.
 :- dynamic filter_on/0.
@@ -73,14 +73,14 @@
 :- dynamic nolabel/0.
 :- dynamic noneq_elim/0.
 :- dynamic noran_elim/0.
-:- dynamic noirules/0.                                 
+:- dynamic noirules/0.
 :- dynamic trace/1.
 
-:- dynamic strategy/1.           % configuration params  
-:- dynamic path/1. 
-:- dynamic rw_rules/1. 
-     
-:- multifile replace_rule/6.     
+:- dynamic strategy/1.           % configuration params
+:- dynamic path/1.
+:- dynamic rw_rules/1.
+
+:- multifile replace_rule/6.
 :- multifile inference_rule/7.
 :- multifile fail_rule/6.
 :- multifile equiv_rule/3.
@@ -90,9 +90,9 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%                                    %%%%%%%%%%%%%%           
-%%%%%%%%%%%   {log} interactive environment    %%%%%%%%%%%%%%               
-%%%%%%%%%%%                                    %%%%%%%%%%%%%%               
+%%%%%%%%%%%                                    %%%%%%%%%%%%%%
+%%%%%%%%%%%   {log} interactive environment    %%%%%%%%%%%%%%
+%%%%%%%%%%%                                    %%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -100,18 +100,18 @@
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-% The following predicates implement the {log} 
-% interactive programming environment. This environment 
+% The following predicates implement the {log}
+% interactive programming environment. This environment
 % offers a Prolog-like user interface, enriched with facilities
 % for manipulating sets and multi-sets. The most notable
-% syntactic differences w.r.t. std Prolog are: the use of '&' in 
-% place of ',' to represent goal conjunction; the  use of 'or' 
-% in place of ';' to represent goal disjunction; the use of 
-% 'neg' or 'naf' in place of '\+' to represent negation (resp., 
-% simplified Constructive Negation and Negation as Failure).  
+% syntactic differences w.r.t. std Prolog are: the use of '&' in
+% place of ',' to represent goal conjunction; the  use of 'or'
+% in place of ';' to represent goal disjunction; the use of
+% 'neg' or 'naf' in place of '\+' to represent negation (resp.,
+% simplified Constructive Negation and Negation as Failure).
 % To enter the {log} interactive environment call the goal
 % 'setlog.'. To exit, call the goal 'halt.'.
-% N.B. {log}, in the current version, provides only a small 
+% N.B. {log}, in the current version, provides only a small
 % subset of Prolog built-ins and no support for program
 % debugging at {log} program level.
 %
@@ -121,46 +121,46 @@ setlog :-
        top_level.
 
 top_level :-
-       retract_nowarning,  
+       retract_nowarning,
        nl, write('{log}=> '),
        setlog_read_term(Goal,[variable_names(VarNames)]),
        solve(Goal,Constr),
-       skip_return, 
+       skip_return,
        add_FDc(Constr,ConstrAll,Warning),
        fd_warning(Warning),
-       chvar([],_,v(VarNames,ConstrAll),_,_,v(VarNames1,Constr1)),  
-       mk_subs_ext(VarNames1,VarNames_ext1),    
+       chvar([],_,v(VarNames,ConstrAll),_,_,v(VarNames1,Constr1)),
+       mk_subs_ext(VarNames1,VarNames_ext1),
        extract_vars(VarNames_ext1,Vars),
        nl, write_subs_constr(VarNames_ext1,Constr1,Vars),
        top_level.
 top_level :-
        nl,write(no),nl,
-       skip_return,  
+       skip_return,
        top_level.
 
-welcome_message :-                                     
+welcome_message :-
        nl, nl,
        write('              WELCOME TO {log} - version 4.7           '),
        nl, nl.
 
 %%%%%%%%%%%%%%%%
 
-setlog_read_term(Goal,Vars) :- 
-       on_exception(Msg,read_term(Goal,Vars),syntax_error_msg(Msg)).  
+setlog_read_term(Goal,Vars) :-
+       on_exception(Msg,read_term(Goal,Vars),syntax_error_msg(Msg)).
 
 syntax_error_msg(Text) :-
-       write('Syntax error:'), nl,   
-       write(Text), nl, 
+       write('Syntax error:'), nl,
+       write(Text), nl,
        fail.
 
-skip_return :-    
+skip_return :-
       read_pending_input(user_input,_C,[]).
 
 %%%%%%%%%%%%%%%%
 
-fd_warning(R) :- 
+fd_warning(R) :-
        var(R),!.
-fd_warning(_) :- 
+fd_warning(_) :-
        print_warning('***WARNING***: non-finite domain').
 
 print_warning(Msg) :-
@@ -175,70 +175,70 @@ retract_nowarning.
 
 %%%%%%%%%%%%%%%%
 
-mk_subs_ext(VarSubs,VarSubsMin) :-      
+mk_subs_ext(VarSubs,VarSubsMin) :-
        postproc(VarSubs,VarSubsExt),
        mk_subs_vv(VarSubsExt,VarSubsMin).
 
-mk_subs_vv([],[]).                  
+mk_subs_vv([],[]).
 mk_subs_vv([N1=V1|Subs],R) :-
        var(V1),!,
        V1 = N1,
        mk_subs_vv(Subs,SubsMin),
-       append(SubsMin,[true],R).  
+       append(SubsMin,[true],R).
 mk_subs_vv([N1=V1|Subs],[N1=V1|R]) :-
-       mk_subs_vv(Subs,R).  
+       mk_subs_vv(Subs,R).
 
 %%%%%%%%%%%%%%%% write substitutions and constraints
 
-write_subs_constr([],[],_) :- !,    
-       write(yes), nl.                       
-write_subs_constr(Subs,Constr,Vars) :-  
+write_subs_constr([],[],_) :- !,
+       write(yes), nl.
+write_subs_constr(Subs,Constr,Vars) :-
       (Subs = [],!, true
-       ; 
+       ;
        Subs = [true|_],!,write('true'),Prn=y
        ;
        write_subs_all(Subs,Prn)
-      ), 
-       write_constr(Constr,Vars,Prn), 
+      ),
+       write_constr(Constr,Vars,Prn),
        ask_the_user(Prn).
 
 ask_the_user(Prn):-
        var(Prn),!.
 ask_the_user(_):-
-       nl,  
+       nl,
        nl, write('Another solution?  (y/n)'),
 %       get(C), skip(10),
-       get_single_char(C), 
-       (C \== 121,! 
-        ; 
+       get_single_char(C),
+       (C \== 121,!
+        ;
         retract_nowarning, fail
        ).
 
 write_subs_all([],_).
 write_subs_all([N1=V1|R],Prn) :-
         write(N1), write(' = '), write(V1), Prn=y,
-       (R = [],!,true ; 
+       (R = [],!,true ;
         R = [true|_],!,true ;
-        write(',  '), nl, write_subs_all(R,Prn) ).  
+        write(',  '), nl, write_subs_all(R,Prn) ).
 
-write_constr(Constr,Vars,Prn) :-             
+write_constr(Constr,Vars,Prn) :-
        postproc(Constr,Constr_ext),
        write_constr_first(Constr_ext,Vars,Prn).
 
-write_constr_first([],_,_) :- !.                
-write_constr_first([C|Constr],Vars,Prn) :-             
-       nl, write('Constraint: '), 
+write_constr_first([],_,_) :- !.
+write_constr_first([C|Constr],Vars,Prn) :-
+       nl, write('Constraint: '),
        write_atomic_constr(C), Prn=y,
        write_constr_all(Constr,Vars).
 
-write_constr_all([],_) :- !.                
-write_constr_all([C|Constr],Vars) :-             
+write_constr_all([],_) :- !.
+write_constr_all([C|Constr],Vars) :-
        write(', '), write_atomic_constr(C),
        write_constr_all(Constr,Vars).
-         
+
 write_atomic_constr(solved(C,_,_,_)) :- !,
        write(C).
-write_atomic_constr(delay(irreducible(C)&true,_)) :- !, 
+write_atomic_constr(delay(irreducible(C)&true,_)) :- !,
     write(irreducible(C)).
 write_atomic_constr(C) :- !,
        write(C).
@@ -248,9 +248,9 @@ write_atomic_constr(C) :- !,
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%               
-%%%%%%%%%%%%%%   Prolog to {log} interface  %%%%%%%%%%%%%%%%%               
-%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%               
+%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%   Prolog to {log} interface  %%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -260,77 +260,77 @@ write_atomic_constr(C) :- !,
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-% The following predicates allow a Prolog program to use the 
+% The following predicates allow a Prolog program to use the
 % {log} facilities for set/bag definition and manipulation
 % (without leaving the Prolog execution environment).
-% In particular, they provide a (Prolog) predicate for calling 
+% In particular, they provide a (Prolog) predicate for calling
 % any {log} goal G, possibly involving {log} set constraints.
-% 
+%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-%%%% setlog(+Goal) 
+%%%% setlog(+Goal)
 %
 setlog(Goal) :-
        setlog(Goal,_).
 
-%%%% setlog(+Goal,-OutConstraintList) 
+%%%% setlog(+Goal,-OutConstraintList)
 %
 setlog(Goal,OutConstrLst) :-
-       nonvar(Goal), 
-       retract_nowarning,  
+       nonvar(Goal),
+       retract_nowarning,
        copy_term(Goal,NewGoal),
        solve(NewGoal,C),
-       remove_solved(C,C1),                   %remove info about "solved" constraints    
+       remove_solved(C,C1),                   %remove info about "solved" constraints
        add_FDc(C1,Constr,Warning),            %add the possibly remaining interval constr's
        fd_warning(Warning),
-       postproc(Constr,OutConstrLst),         %from 'with' to {...} notation  
+       postproc(Constr,OutConstrLst),         %from 'with' to {...} notation
        postproc(NewGoal,NewGoal_ext),
        postproc(Goal,Goal_ext),
        Goal_ext = NewGoal_ext.                %apply sustitutions to the original variables
 
-%%%% setlog(+Goal,+InConstraintList,-OutConstraintList) 
+%%%% setlog(+Goal,+InConstraintList,-OutConstraintList)
 %
-setlog(Goal,InConstrLst,OutConstrLst) :-  
+setlog(Goal,InConstrLst,OutConstrLst) :-
        nonvar(Goal), nonvar(InConstrLst),
-       retract_nowarning,  
-       list_to_conj(InConstr,InConstrLst),             %from list (InConstrLst) to conjunction (InConstr)     
+       retract_nowarning,
+       list_to_conj(InConstr,InConstrLst),             %from list (InConstrLst) to conjunction (InConstr)
        conj_append(Goal,InConstr,ExtdGoal),
        copy_term(ExtdGoal,NewGoal),
        solve(NewGoal,OutCLstIntl),
        remove_solved(OutCLstIntl,ROutCLstIntl),        %remove info about "solved" constraints
        add_FDc(ROutCLstIntl,OutFinalCLstIntl,Warning), %add the possibly remaining interval constr's
        fd_warning(Warning),
-       postproc(OutFinalCLstIntl,OutConstrLst),        %from 'with' to {...} notation      
+       postproc(OutFinalCLstIntl,OutConstrLst),        %from 'with' to {...} notation
        postproc(NewGoal,NewGoal_ext),
        postproc(ExtdGoal,ExtdGoal_ext),
-       ExtdGoal_ext = NewGoal_ext.                     %apply sustitutions to the original variables         
+       ExtdGoal_ext = NewGoal_ext.                     %apply sustitutions to the original variables
 
-%%%% setlog_partial(+Goal,+InConstraintList,-OutConstraintList) 
+%%%% setlog_partial(+Goal,+InConstraintList,-OutConstraintList)
 %
-setlog_partial(Goal,InConstrLst,OutConstrLst) :-  
+setlog_partial(Goal,InConstrLst,OutConstrLst) :-
        nonvar(Goal), nonvar(InConstrLst),
-       retract_nowarning,  
-       list_to_conj(InConstr,InConstrLst),    %from list (InConstrLst) to conjunction (InConstr)     
+       retract_nowarning,
+       list_to_conj(InConstr,InConstrLst),    %from list (InConstrLst) to conjunction (InConstr)
        conj_append(Goal,InConstr,ExtdGoal),
-       copy_term(ExtdGoal,NewGoal),       
+       copy_term(ExtdGoal,NewGoal),
        transform_goal(NewGoal,B),             %from extl to internal repr. (remove SF, RUQ, {...})
        solve_goal(B,Constr),                  %call the constraint solver (in 'non-final' mode)
-       postproc(Constr,OutConstrLst),         %from 'with' to {...} notation     
+       postproc(Constr,OutConstrLst),         %from 'with' to {...} notation
        postproc(NewGoal,NewGoal_ext),
        postproc(ExtdGoal,ExtdGoal_ext),
-       ExtdGoal_ext = NewGoal_ext.            %apply sustitutions to the original variables             
+       ExtdGoal_ext = NewGoal_ext.            %apply sustitutions to the original variables
 
-%%%% setlog_sc(+Constraint,+InConstraintList,-OutConstraintList) 
+%%%% setlog_sc(+Constraint,+InConstraintList,-OutConstraintList)
 %
 setlog_sc(Constr,InConstrLst,OutConstrLst) :- %to solve {log} set constraints (partial solve)
        nonvar(Constr), nonvar(InConstrLst),
-       retract_nowarning,  
-       list_to_conj(InConstr,InConstrLst),    %from list (InConstrLst) to conjunction (InConstr) 
+       retract_nowarning,
+       list_to_conj(InConstr,InConstrLst),    %from list (InConstrLst) to conjunction (InConstr)
        conj_append(Constr,InConstr,CS),
        copy_term(CS,NewCS),
-       preproc_goal(NewCS,NewCSIntl),         %from {...} to 'with' notation;   
+       preproc_goal(NewCS,NewCSIntl),         %from {...} to 'with' notation;
        solve_goal(NewCSIntl,OutCLstIntl),     %call the constraint solver (in 'non-final' mode)
-       postproc(OutCLstIntl,OutConstrLst),    %from 'with' to {...} notation  
+       postproc(OutCLstIntl,OutConstrLst),    %from 'with' to {...} notation
        postproc(CS,CSExt),
        postproc(NewCS,NewCSExt),
        CSExt = NewCSExt.                      %apply sustitutions to the original variables
@@ -376,41 +376,41 @@ setlog_clear :-
        ssolve(neq_elim,[],[]),
        ssolve(ran_elim,[],[]).
 
-%%%% other predicates for Prolog to {log} interface 
+%%%% other predicates for Prolog to {log} interface
 
 setlog_consult(File) :-                   %like setlog(consult(File))
        setlog(consult(File,mute),_).      %but no message is sent to the std output
 
-setlog_clause(Clause) :-                  %for compatibility with previous versions      
+setlog_clause(Clause) :-                  %for compatibility with previous versions
        setlog(assert(Clause),_).
 
 consult_lib :-                            %to consult the {log} library file
-       setlog(consult_lib,_).             
+       setlog(consult_lib,_).
 
 setlog_config(ConfigParams) :-            %to modify {log}'s configuration parameters
-       set_params(ConfigParams).                      
-  
+       set_params(ConfigParams).
+
 setlog_rw_rules :-                        %to load the filtering rule library
        rw_rules(Lib),
        mk_file_name(Lib,FullName),
-       consult(FullName). 
- 
-%%%% auxiliary predicates for Prolog to {log} interface 
+       consult(FullName).
+
+%%%% auxiliary predicates for Prolog to {log} interface
 
 remove_solved([],[]).
 remove_solved([solved(C,_,_,_)|R],[C|RR]) :- !,
     remove_solved(R,RR).
-remove_solved([delay(irreducible(C)&true,_)|R],[irreducible(C)|RR]) :- !, 
+remove_solved([delay(irreducible(C)&true,_)|R],[irreducible(C)|RR]) :- !,
     remove_solved(R,RR).
 remove_solved([C|R],[C|RR]) :-
     remove_solved(R,RR).
-   
-set_params([]).                          
+
+set_params([]).
 set_params([P1|ParamsList]) :-
     apply_params(P1),
     set_params(ParamsList).
 
-apply_params(strategy(Str)) :- !,         
+apply_params(strategy(Str)) :- !,
     replace_unitCl(strategy(_),Str).
 apply_params(path(Path)) :- !,
     replace_unitCl(path(_),Path).
@@ -418,9 +418,9 @@ apply_params(rw_rules(FileName)) :- !,
     replace_unitCl(rw_rules(_),FileName).
 %%% to be continued
 
-replace_unitCl(Cl,NewParm) :-             
+replace_unitCl(Cl,NewParm) :-
     retract(Cl),!,
-    Cl =.. [F,_X], NewCl =.. [F,NewParm], 
+    Cl =.. [F,_X], NewCl =.. [F,NewParm],
     assert(NewCl).
 
 
@@ -428,18 +428,18 @@ replace_unitCl(Cl,NewParm) :-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%               
-%%%%%%%%%%%%%%        The help sub-system   %%%%%%%%%%%%%%%%%               
-%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%               
+%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%        The help sub-system   %%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-setlog_help :- h(setlog).           
+setlog_help :- h(setlog).
 
-h(setlog) :- 
-   nl, 
+h(setlog) :-
+   nl,
    write('   -   h(syntax), h(constraints), h(builtins), h(lib), h(prolog) to get help '), nl,
    write('       information (resp., about: {log} syntactic convenctions, {log} constraints, '), nl,
    write('       {log} built-in predicates, {log} library predicates, Prolog predicates'), nl,
@@ -454,42 +454,42 @@ h(setlog) :-
    write('       and output constraint list OutCLst '), nl.
 
 h(all) :-
-   h(syntax), 
+   h(syntax),
    h(constraints),
    h(builtins),
    h(prolog),
    h(lib).
 
-h(syntax) :- 
-   nl,    
+h(syntax) :-
+   nl,
    write('%%%%%%%%%   Syntactic conventions  %%%%%%%%%'),
    nl, nl,
-write('   1.  Extensional set/multiset terms:'), nl,                  
+write('   1.  Extensional set/multiset terms:'), nl,
    write('        - {a,b,c} is a set containing three elements, a, b, c'),nl,
-   write('          (equivalent to {} with c with b with a)'), nl,         
-   write('        - {a,b\\R} is the set {a,b} U R'), nl,          
-   write('          (equivalent to R with b with a)'), nl,       
+   write('          (equivalent to {} with c with b with a)'), nl,
+   write('        - {a,b\\R} is the set {a,b} U R'), nl,
+   write('          (equivalent to R with b with a)'), nl,
    write('        - *({a,b,b}) (or, * {a,b,b}) is a multiset containing the elements,'),nl,
-   write('          ''a'' (1 occurrence) and  ''b'' (2 occurrences)'),nl,   
-   write('          (equivalent to {} mwith c mwith b mwith a)'), nl,         
-   write('        - *({a,b\\R}) is the multiset *({a,b}) U R'), nl,      
-   write('          (equivalent to R mwith b mwith a)'), nl,       
-   write('        - {} is the empty set/multiset'), nl,                             
+   write('          ''a'' (1 occurrence) and  ''b'' (2 occurrences)'),nl,
+   write('          (equivalent to {} mwith c mwith b mwith a)'), nl,
+   write('        - *({a,b\\R}) is the multiset *({a,b}) U R'), nl,
+   write('          (equivalent to R mwith b mwith a)'), nl,
+   write('        - {} is the empty set/multiset'), nl,
    write('        - int(h,k) (interval, h,k integer constants) is the set of'), nl,
-   write('          integer numbers ranging from h to k (k>=h) or the empty set (k<h)'), nl, 
-   nl,      
-write('   2.  RUQs: '), nl,                            
+   write('          integer numbers ranging from h to k (k>=h) or the empty set (k<h)'), nl,
+   nl,
+write('   2.  RUQs: '), nl,
    write('       (''a'' either a set or a multiset or a list or an interval int(h,k))'), nl,
-   write('        - forall(X in a, G),'), nl, 
-   write('          X variable and G any {log} goal containing X'), nl,  
+   write('        - forall(X in a, G),'), nl,
+   write('          X variable and G any {log} goal containing X'), nl,
    write('        - forall(X in a, exists(V,G)),'),nl,
-   write('        - forall(X in a, exists([V1,...,Vn],G)),'), nl, 
+   write('        - forall(X in a, exists([V1,...,Vn],G)),'), nl,
    write('          V1,...,Vn variables local to G'), nl,
    nl,
-write('   3.  Intensional set terms:'), nl,                                 
+write('   3.  Intensional set terms:'), nl,
    write('        - {X : G}, X variable and G any {log} goal containing X'), nl,
    write('        - {X : exists(V,G)}, V variable local to G'), nl,
-   write('        - {X : exists([V1,...,Vn],G)}, '), nl, 
+   write('        - {X : exists([V1,...,Vn],G)}, '), nl,
    write('          V1,...,Vn variables local to G'), nl,
    nl,
 write('   4.  Syntactic differences w.r.t. std Prolog:'), nl,
@@ -498,30 +498,30 @@ write('   4.  Syntactic differences w.r.t. std Prolog:'), nl,
                     write('  to represent goal disjunction.'), nl,
    write('        - neg or naf are used in place of  \\+'),
                     write('  to represent negation (resp., '), nl,
-   write('          simplified Constructive Negation and Negation as Failure)'),  
-   nl.    
+   write('          simplified Constructive Negation and Negation as Failure)'),
+   nl.
 
-h(constraints) :- 
-   nl,    
+h(constraints) :-
+   nl,
    write('%%%%%%%%%   {log} constraints  %%%%%%%%%'),
    nl, nl,
 write('   1.  General constraints:'), nl,
    write('       (''t_i'' any term, including non-ground intervals)'), nl,
    write('        - t1 = t2  (equality)'), nl,
-   write('        - t1 neq t2  (non-equality)'), nl, 
-   nl, 
+   write('        - t1 neq t2  (non-equality)'), nl,
+   nl,
 write('   2.  Set/multiset/list constraints:'), nl,
    write('       (''t'',''t_i'' any term, including non-ground intervals,'), nl,
    write('        ''s'',''s_i'' either a set or a bounded interval,'), nl,
    write('        ''sint'' either a set of non-negative integers or a bounded interval,'), nl,
    write('        ''n'' a variable or an integer constant)'), nl,
    write('        - t1 in t2 (membership)'), nl,
-   write('        - t1 nin t2 (non-membership)'), nl,   
+   write('        - t1 nin t2 (non-membership)'), nl,
    write('        - inters(t1,t2,t3) (intersection)'), nl,
    write('        - un(s1,s2,s3) (union)'), nl,
-   write('        - nun(s1,s2,s3) (non-union)'), nl,   
+   write('        - nun(s1,s2,s3) (non-union)'), nl,
    write('        - disj(s1,s2) (disjointness)'), nl,
-   write('        - ndisj(s1,s2) (non-disjointness)'), nl,  
+   write('        - ndisj(s1,s2) (non-disjointness)'), nl,
    write('        - less(s1,t,s3) (element removal)'), nl,
    write('        - subset(s1,s2) (subset)'), nl,
    write('        - nsubset(s1,s2) (not subset)'), nl,
@@ -534,41 +534,41 @@ write('   2.  Set/multiset/list constraints:'), nl,
    write('        - sum(sint,n) (sum all elements (non-negative integers only))'), nl,
    write('        - smin(sint,n) (minimum element)'), nl,
    write('        - smax(sint,n) (maximum element)'), nl,
-   write('        - set(t) (t is a set)'), nl,  
-   write('        - bag(t) (t is a multiset)'), nl, 
-   write('        - list(t) (t is a list)'), nl, 
-   write('        - npair(t) (t is not a pair)'), nl, 
+   write('        - set(t) (t is a set)'), nl,
+   write('        - bag(t) (t is a multiset)'), nl,
+   write('        - list(t) (t is a list)'), nl,
+   write('        - npair(t) (t is not a pair)'), nl,
    nl,
 write('   3.  Integer constraints:'), nl,
    write('       (''e_i'' an integer expression, ''n'' a variable or an integer constant)'), nl,
    write('        - n is e1 (equality - with evaluation of expression e)'), nl,
-   write('        - e1 =< e2 (less or equal), e1 < e2 (less)'), nl,  
-   write('        - e1 >= e2 (greater or equal), e1 > e2 (greater)'), nl,  
-   write('        - e1 =:= e2 (equal), e1 =\\= e2 (not equal)'), nl,  
-   write('        - integer(n) (n is an integer number)'), nl,  
-   write('        - ninteger(n) (n is not an integer number)'),nl,   
-   nl, 
-write('   4.  Binary relation and partial function constraints:'), nl,   
+   write('        - e1 =< e2 (less or equal), e1 < e2 (less)'), nl,
+   write('        - e1 >= e2 (greater or equal), e1 > e2 (greater)'), nl,
+   write('        - e1 =:= e2 (equal), e1 =\\= e2 (not equal)'), nl,
+   write('        - integer(n) (n is an integer number)'), nl,
+   write('        - ninteger(n) (n is not an integer number)'),nl,
+   nl,
+write('   4.  Binary relation and partial function constraints:'), nl,
    write('       (''t'' any term, "s",  ''s_i'' either a set or a bounded interval,'), nl,
    write('         ''r'', ''r_i'' a binary relation, ''f'' a partial function)'), nl,
-   write('        - rel(t)/nrel(t) (t is/is_not a binary relation)'), nl,  
-   write('        - dom(r,s) (domain)'), nl,   
-   write('        - ran(r,s) (range)'), nl,   
-   write('        - inv(r,s) (inverse relation)'), nl,   
-   write('        - comp(r1,r2,r3) (composition)'), nl, 
-   write('        - dres(s,r1,r2) (domain restriction)'), nl,   
-   write('        - rres(s,r1,r2) (range restriction)'), nl,   
-   write('        - ndres(s,r1,r2) domain anti-restriction)'), nl,   
-   write('        - nrres(s,r1,r2) (range anti-restriction)'), nl, 
-   write('        - rimg(s1,r,s2) (relational image)'), nl,   
-   write('        - oplus(r1,r2,r3) (overriding)'), nl,  
-   write('        - pfun(t)/npfun(t)(t is/is_not a partial function)'), nl,  
-   write('        - apply(f,t1,t2) (function application)'), nl,  
-   write('        - id(s,f) (identity relation)'), nl,   
-   write('        - dompf(f,s) (domain of a partial function)'), nl,   
-   write('        - comppf(r1,f,r2) (composition of partial functions)'), nl, 
+   write('        - rel(t)/nrel(t) (t is/is_not a binary relation)'), nl,
+   write('        - dom(r,s) (domain)'), nl,
+   write('        - ran(r,s) (range)'), nl,
+   write('        - inv(r,s) (inverse relation)'), nl,
+   write('        - comp(r1,r2,r3) (composition)'), nl,
+   write('        - dres(s,r1,r2) (domain restriction)'), nl,
+   write('        - rres(s,r1,r2) (range restriction)'), nl,
+   write('        - ndres(s,r1,r2) domain anti-restriction)'), nl,
+   write('        - nrres(s,r1,r2) (range anti-restriction)'), nl,
+   write('        - rimg(s1,r,s2) (relational image)'), nl,
+   write('        - oplus(r1,r2,r3) (overriding)'), nl,
+   write('        - pfun(t)/npfun(t)(t is/is_not a partial function)'), nl,
+   write('        - apply(f,t1,t2) (function application)'), nl,
+   write('        - id(s,f) (identity relation)'), nl,
+   write('        - dompf(f,s) (domain of a partial function)'), nl,
+   write('        - comppf(r1,f,r2) (composition of partial functions)'), nl,
    nl.
-        
+
 h(builtins) :-
    h(sbuilt),
    h(pbuilt).
@@ -580,29 +580,29 @@ h(sbuilt) :-
    write('   -   halt/0: to leave the {log} interactive environment'),
         write(' (go back to the host environment) '), nl,
    write('   -   help/0: to get general help information about {log}'), nl,
-   write('   -   prolog_call(G): to call any Prolog goal G from {log}'),nl,  
-   write('   -   call(G), call(G,C): to call a {log} goal G, possibly with constraint C'),nl,  
-   write('   -   solve(G): like call(G) but all constraints generated by G are immediately solved'),nl,  
-   write('   -   consult_lib/0: to consult the {log} library file setloglib.slog'),nl,  
-   write('   -   add_lib(F): to add any file F to the {log} library '),nl,  
+   write('   -   prolog_call(G): to call any Prolog goal G from {log}'),nl,
+   write('   -   call(G), call(G,C): to call a {log} goal G, possibly with constraint C'),nl,
+   write('   -   solve(G): like call(G) but all constraints generated by G are immediately solved'),nl,
+   write('   -   consult_lib/0: to consult the {log} library file setloglib.slog'),nl,
+   write('   -   add_lib(F): to add any file F to the {log} library '),nl,
    write('   -   G!: to make a {log} goal G deterministic'), nl,
-   write('   -   delay(G,C), G, C {log} goals: to delay execution of G '),nl,     
+   write('   -   delay(G,C), G, C {log} goals: to delay execution of G '),nl,
    write('       until either C holds or the computation ends; '), nl,
    write('   -   delay(irreducible(G),C), G, C {log} goals: to delay execution of G '),nl,
    write('       until C holds; otherwise return irreducible(G)'), nl,
    write('   -   nolabel/0, label/0: to deactivate/activate the global FD labeling'),nl,
-   write('       (default: label)'), nl, 
+   write('       (default: label)'), nl,
    write('   -   labeling(X): to force labeling for the domain variable X'),nl,
    write('   -   strategy(S): to change goal atom selection strategy to S'),nl,
-   write('       (S: cfirst, ordered, cfirst(list_of_atoms))'), nl, 
+   write('       (S: cfirst, ordered, cfirst(list_of_atoms))'), nl,
    write('   -   notrace/0, trace(Mode): to deactivate/activate constraint solving tracing; '),nl,
-   write('       Mode=sat: general, Mode=irules: inference rules only (default: notrace)'), nl, 
+   write('       Mode=sat: general, Mode=irules: inference rules only (default: notrace)'), nl,
    write('   -   noneq_elim/0, neq_elim/0: to deactivate/activate elimination of neq-'),nl,
-   write('       constraints (default: neq_elim)'), nl, 
+   write('       constraints (default: neq_elim)'), nl,
    write('   -   nonran_elim/0, ran_elim/0: to deactivate/activate elimination of ran-'),nl,
-   write('       constraints of the form ran(R,{...}) (default: ran_elim)'), nl, 
+   write('       constraints of the form ran(R,{...}) (default: ran_elim)'), nl,
    write('   -   noirules/0, irules/0: to deactivate/activate inference rules '),nl,
-   write('       (default: irules)'), nl, 
+   write('       (default: irules)'), nl,
    write('   -   time(G,T): to get CPU time (in milliseconds) for solving goal G'),
    nl.
 
@@ -618,14 +618,14 @@ h(pbuilt) :-
    write('   -   consult/1'),nl,
    write('   -   listing/0'),nl,
    write('   -   abolish/0'),nl.
-  
+
 h(lib) :-
    nl,
    write('%%%%%%%% {log} library %%%%%%%%'), nl, nl,
    check_lib,
-   nl. 
+   nl.
 
-h(prolog) :- 
+h(prolog) :-
    nl,
    write('%%%%%%%% Prolog predicates for accessing {log} facilities %%%%%%%%%'),
    nl,nl,
@@ -643,13 +643,13 @@ h(prolog) :-
    write('       (parameters: strategy(S), path(Path), rw_rules(File))'), nl,
    write('   -   setlog_rw_rules: to load the filtering rule library'),
    nl.
- 
+
 write_built_list :-
    sys(N,Ar),
    write('   -   '),write(N),write('/'),write(Ar),nl,
    fail.
 write_built_list.
- 
+
 check_lib :-
    solve(setlog_lib_help,_),!.
 check_lib :-
@@ -661,19 +661,19 @@ check_lib :-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%               
-%%%%%%%%%%%%%%     The inference engine     %%%%%%%%%%%%%%%%%               
-%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%               
+%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%     The inference engine     %%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-        
+
 %%%% solve(+Goal,-Constraint)            Goal: {log} goal in external form
 %
-solve(Goal_int_ruq,Constr):-   
+solve(Goal_int_ruq,Constr):-
        transform_goal(Goal_int_ruq,B),
-%DBG%  nl,write('NEW GOAL: '),write(B),nl, 
+%DBG%  nl,write('NEW GOAL: '),write(B),nl,
        solve_goal_fin(B,Constr).
 
 %%%% solve_goal_fin(+Goal,-Constraint)   Goal: {log} goal in internal form
@@ -682,22 +682,22 @@ solve_goal_fin(G,ClistNew) :-
        constrlist(G,GClist,GAlist),
        solve_goal_fin_constr(GClist,GAlist,ClistNew).
 
-solve_goal_fin_constr(GClist,GAlist,ClistNew):-  
-       solve_goal_constr(GClist,GAlist,Clist), 
+solve_goal_fin_constr(GClist,GAlist,ClistNew):-
+       solve_goal_constr(GClist,GAlist,Clist),
        final_sat(Clist,ClistNew).
 
 %%%% solve_goal(+Goal,-Constraint)       Goal: {log} goal in internal form
 %
 solve_goal(G,ClistNew) :-
        constrlist(G,GClist,GAlist),
-       solve_goal_constr(GClist,GAlist,ClistNew). 
+       solve_goal_constr(GClist,GAlist,ClistNew).
 
 %%%% solve_goal_constr(+Constraint,+Non_Constraint,-Constraint)
 %
-solve_goal_constr(Clist,[],CListCan):- !, 
-       sat(Clist,CListCan,nf). 
-solve_goal_constr(Clist,[true],CListCan):- !, 
-       sat(Clist,CListCan,nf). 
+solve_goal_constr(Clist,[],CListCan):- !,
+       sat(Clist,CListCan,nf).
+solve_goal_constr(Clist,[true],CListCan):- !,
+       sat(Clist,CListCan,nf).
 solve_goal_constr(Clist,[A|B],CListOut):-
        sat(Clist,ClistSolved,nf),
        sat_or_solve(A,ClistSolved,ClistNew,AlistCl,nf),
@@ -712,7 +712,7 @@ sat_or_solve(A,Clist_in,Clist_out,Alist_out,_) :-
        append(Clist_in,ClistCl,Clist_out).
 
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%% ssolve(+Atom,-Constraint,-Non_Constraint)
 
 ssolve(true,[],[]):- !.                  %% unit goal
@@ -722,51 +722,51 @@ ssolve(neg A,ClistNew,[]):-              %% simplified constructive negation
 ssolve(naf A,ClistNew,[]):-              %% negation as failure
         !,naf_negate(A,ClistNew).
 
-ssolve((G1 or G2),ClistNew,[]):-         %% goal disjunction 
+ssolve((G1 or G2),ClistNew,[]):-         %% goal disjunction
         !,(solve_goal(G1,ClistNew)
           ;
            solve_goal(G2,ClistNew) ).
 
-ssolve(call(A),C,[]):-                   %% meta call    
+ssolve(call(A),C,[]):-                   %% meta call
         !,solve_goal(A,C).
 
-ssolve(call(A,C),C,[]):-                 %% meta call       
+ssolve(call(A,C),C,[]):-                 %% meta call
         !,solve_goal(A,C).
 
-ssolve(solve(A),C,[]):-                  %% forces goal A to be completely solved    
+ssolve(solve(A),C,[]):-                  %% forces goal A to be completely solved
         !,solve_goal_fin(A,C).
 
 ssolve((A)!,C,[]):-                      %% deterministic call
         !,solve_goal(A,C),!.
-  
+
 ssolve(ruq_call(S,InName,VarList),Cout,[]) :-       %% RUQs
-        !,solve_RUQ(S,InName,VarList,[],Cout).   
+        !,solve_RUQ(S,InName,VarList,[],Cout).
 
 ssolve(sf_call(S,GName,PName,VarList),Cout,[]) :-   %% SF
-        !, solve_SF(S,GName,PName,VarList,[],Cout).   
+        !, solve_SF(S,GName,PName,VarList,[],Cout).
 
 ssolve(prolog_call(A),[],[]):-    %% Prolog call (any predicate)
-        nonvar(A),!,A.   
-                 
+        nonvar(A),!,A.
+
 ssolve(A,[],[]):-                 %% Prolog built-in predicates
         nonvar(A),functor(A,F,N),
-        sys(F,N),!,A.   
+        sys(F,N),!,A.
 
 ssolve(A,C,[]):-                  %% {log} built-in predicates
-        sys_special(A,C),!.   
+        sys_special(A,C),!.
 
 ssolve(labeling(X),[],[]):-       %% explicit clpfd labeling
-        nonvar(X),!. 
-ssolve(labeling(X),[],[]):- !,    
-        get_domain(X,X in D), 
-        labeling1(X,D).                
+        nonvar(X),!.
+ssolve(labeling(X),[],[]):- !,
+        get_domain(X,X in D),
+        labeling1(X,D).
 
 ssolve(label,[],[]):- !,          %% (re-)activate automatic clpfd labeling
         retract_nolabel.
 
 ssolve(nolabel,[],[]):-           %% deactivate automatic clpfd labeling
         nolabel,!.
-ssolve(nolabel,[],[]):-    
+ssolve(nolabel,[],[]):-
         assert(nolabel).
 
 ssolve(notrace,[],[]):- !,        %% deactivate constraint solving tracing
@@ -774,10 +774,10 @@ ssolve(notrace,[],[]):- !,        %% deactivate constraint solving tracing
 
 ssolve(trace(sat),[],[]):-        %% activate constraint solving tracing
         trace(sat),!.
-ssolve(trace(irules),[],[]):-        
+ssolve(trace(irules),[],[]):-
         trace(irules),!.
-ssolve(trace(Mode),[],[]):-  
-        (Mode==sat,! ; Mode==irules),   
+ssolve(trace(Mode),[],[]):-
+        (Mode==sat,! ; Mode==irules),
         assert(trace(Mode)).
 
 ssolve(neq_elim,[],[]):- !,       %% (re-)activate automatic neq elimination
@@ -785,7 +785,7 @@ ssolve(neq_elim,[],[]):- !,       %% (re-)activate automatic neq elimination
 
 ssolve(noneq_elim,[],[]):-        %% deactivate automatic neq elimination
         noneq_elim.
-ssolve(noneq_elim,[],[]):-     
+ssolve(noneq_elim,[],[]):-
         assert(noneq_elim).
 
 ssolve(ran_elim,[],[]):- !,       %% (re-)activate automatic ran elimination
@@ -793,7 +793,7 @@ ssolve(ran_elim,[],[]):- !,       %% (re-)activate automatic ran elimination
 
 ssolve(noran_elim,[],[]):-        %% deactivate automatic ran elimination
         noran_elim.
-ssolve(noran_elim,[],[]):-     
+ssolve(noran_elim,[],[]):-
         assert(noran_elim).
 
 ssolve(irules,[],[]):- !,         %% (re-)activate automatic application of inference rules
@@ -801,10 +801,10 @@ ssolve(irules,[],[]):- !,         %% (re-)activate automatic application of infe
 
 ssolve(noirules,[],[]):-          %% deactivate automatic application of inference rules
         noirules,!.
-ssolve(noirules,[],[]):-    
+ssolve(noirules,[],[]):-
         assert(noirules).
 
-ssolve(strategy(Str),[],[]):- !,  %% change goal atom selection strategy    
+ssolve(strategy(Str),[],[]):- !,  %% change goal atom selection strategy
         retract(strategy(_)),!,
         assert(strategy(Str)).
 
@@ -815,7 +815,7 @@ ssolve(A,C,D):-                   %% program defined predicates
 our_clause(A,B,C):-
         functor(A,Pname,N),
         functor(P,Pname,N),
-        isetlog((P :- B),_), 
+        isetlog((P :- B),_),
         sunify(P,A,C).
 
 retract_nolabel :-
@@ -841,35 +841,35 @@ retract_trace.
 
 %%%% constrlist(+Atom_conj,-Constraint_list,-Constraint/Non_Constraint_list)
 
-constrlist(A,CList,C_NCList) :-    
+constrlist(A,CList,C_NCList) :-
         constrlist(A,CList,StdC_NCList,SpecC_NCList),
         append(SpecC_NCList,StdC_NCList,C_NCList).
 constrlist(A & B,[A|B1],B2,B3):-
-        selected_atomic_constr(A),!,  
-        constrlist(B,B1,B2,B3).         
+        selected_atomic_constr(A),!,
+        constrlist(B,B1,B2,B3).
 constrlist(A & B,B1,B2,[A|B3]):-
-        selected_user_atom(A),!,  
-        constrlist(B,B1,B2,B3).         
+        selected_user_atom(A),!,
+        constrlist(B,B1,B2,B3).
 constrlist(A & B,B1,[A|B2],B3):-
-        !,constrlist(B,B1,B2,B3).                       
+        !,constrlist(B,B1,B2,B3).
 constrlist(A,[A],[],[]):-
-        selected_atomic_constr(A),!.   
+        selected_atomic_constr(A),!.
 constrlist(A,[],[],[A]):-
-        selected_user_atom(A),!.   
+        selected_user_atom(A),!.
 constrlist(A,[],[A],[]).
 
-selected_atomic_constr(A) :-       
-        strategy(cfirst),!,        %% cfirst: select primitive constraints first    
+selected_atomic_constr(A) :-
+        strategy(cfirst),!,        %% cfirst: select primitive constraints first
         atomic_constr(A).
 selected_atomic_constr(A) :-
         strategy(cfirst(_)),!,
         atomic_constr(A).
 selected_atomic_constr(A) :-
-        strategy(ordered),!,       %% ordered: select all atoms in the order they occur    
+        strategy(ordered),!,       %% ordered: select all atoms in the order they occur
         A = (_ = _).
 
-selected_user_atom(A) :-           
-        strategy(cfirst(LAtoms)),  %% cfirst(LAtoms): select atoms in LAtoms just after primitive constraints  
+selected_user_atom(A) :-
+        strategy(cfirst(LAtoms)),  %% cfirst(LAtoms): select atoms in LAtoms just after primitive constraints
         member(A,LAtoms).
 
 
@@ -882,34 +882,34 @@ naf_negate(A,[]) :-                 %% Negation as Failure
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-c_negate(A,ClistNew) :-             %% Simplified Constructive Negation 
+c_negate(A,ClistNew) :-             %% Simplified Constructive Negation
        chvar([],L1,A,[],L1new,B),
        constrlist(B,Clist,Alist),
        solve_goal_fin_constr(Clist,Alist,Clist0),
-       final_sat(Clist0,Clist1),!, 
+       final_sat(Clist0,Clist1),!,
        dis(L1,L1new,Dis),
        append(Clist1,Dis,CC),
        neg_solve(CC,ClistNew,L1).
-c_negate(_A,[]). 
-       
+c_negate(_A,[]).
+
 neg_solve([],[],_) :- !, fail.
 neg_solve(Clist,ClistNew,LVars) :-
-       neg_constr_l(Clist,ClistNew,LVars).     
+       neg_constr_l(Clist,ClistNew,LVars).
 
 neg_constr_l([],_,_) :- !,fail.
 neg_constr_l(Clist,ClistNew,LVars) :-
        member(C,Clist),
-       neg_constr(C,ClistNew,LVars).       
+       neg_constr(C,ClistNew,LVars).
 
-neg_constr(A nin B,[A in B],_) :- !.           
-neg_constr(A neq B,[],LVars) :- !,            
+neg_constr(A nin B,[A in B],_) :- !.
+neg_constr(A neq B,[],LVars) :- !,
       extract_vars(B,V),
       subset_strong(V,LVars),
-      sunify(A,B,_).     
-neg_constr(A = B,[A neq B],LVars) :-   
+      sunify(A,B,_).
+neg_constr(A = B,[A neq B],LVars) :-
       extract_vars(B,V),
       subset_strong(V,LVars),!.
-neg_constr(_A = _B,_,_) :-   
+neg_constr(_A = _B,_,_) :-
       print_warning('***WARNING***: unimplemented form of negation').
 
 dis([],[],[]):-!.
@@ -922,25 +922,25 @@ dis([X|L1],[Y|L2],[X=Y|L3]):-
       dis(L1,L2,L3).
 dis([X|L1],[Y|L2],L3):-
       X=Y,
-      dis(L1,L2,L3).     
+      dis(L1,L2,L3).
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%  Intensional sets and RUQs processing   
+%%%%%%%%  Intensional sets and RUQs processing
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Intensional sets
 
-solve_SF(S,_GName,PName,VarList,Cin,Cout) :- 
+solve_SF(S,_GName,PName,VarList,Cin,Cout) :-
         nonvar(S), S = {},!,
-        InPred =.. [PName,{}|VarList],     
+        InPred =.. [PName,{}|VarList],
         solve_goal_fin_constr(Cin,[neg(InPred & true)],Cout).
         % print_warning_SF(VarList).
-solve_SF({},_GName,PName,VarList,Cin,Cout) :- 
-        InPred =.. [PName,{}|VarList],     
+solve_SF({},_GName,PName,VarList,Cin,Cout) :-
+        InPred =.. [PName,{}|VarList],
         solve_goal_fin_constr(Cin,[neg(InPred & true)],Cout).
         % print_warning_SF(VarList).
-solve_SF(S,GName,_PName,VarList,_Cin,Cout) :- 
+solve_SF(S,GName,_PName,VarList,_Cin,Cout) :-
         InPred =.. [GName,X|VarList],
         setof(X,solve_goal_fin(InPred,C1),L),
         list_to_set(L,S,C2),
@@ -948,14 +948,14 @@ solve_SF(S,GName,_PName,VarList,_Cin,Cout) :-
         % print_warning_SF(VarList).
 
 %print_warning_SF(VarList) :-      % uncomment to check possibly unsafe uses of intensional sets
-%         \+ground(VarList),!,     
+%         \+ground(VarList),!,
 %         print_warning('***WARNING***: uninstantiated free vaiable in intensional set').
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% RUQs
 
 solve_RUQ(S,_,_,C,C) :-
-        nonvar(S), 
+        nonvar(S),
         empty_aggr(S),!.
 solve_RUQ(S,InName,VarList,Cin,Cout) :-
         nonvar(S), S = int(L,H),!,                % solve RUQ's over intervals
@@ -970,16 +970,16 @@ solve_RUQ(S,InName,VarList,Cin,Cout) :-           % over a given aggregate
 solve_RUQ(S,_,_,C,C) :-
         var(S), S = {}.
 solve_RUQ(S,InName,VarList,Cin,Cout) :-           % over an unspecified aggregate
-        var(S), S = R with X,                             
+        var(S), S = R with X,
         InPred =.. [InName,X|VarList],
         solve_goal_fin_constr([X nin R|Cin],[InPred],C2),
-        solve_RUQ(R,InName,VarList,C2,Cout), 
+        solve_RUQ(R,InName,VarList,C2,Cout),
         aggr_ordered(S).
 
-solve_RUQ_int(int(L,L),InName,VarList,Cin,Cout) :- !,   
+solve_RUQ_int(int(L,L),InName,VarList,Cin,Cout) :- !,
         InPred =.. [InName,L|VarList],    % forall(X in int(L,L),InName(X,VarList))
         solve_goal_fin_constr(Cin,[InPred],Cout).
-solve_RUQ_int(int(L,H),InName,VarList,Cin,Cout) :-    
+solve_RUQ_int(int(L,H),InName,VarList,Cin,Cout) :-
         InPred =.. [InName,L|VarList],    % forall(X in int(L,H),InName(X,VarList))
         solve_goal_fin_constr(Cin,[InPred],C2),
         L1 is L + 1,
@@ -989,29 +989,29 @@ solve_RUQ_int(int(L,H),InName,VarList,Cin,Cout) :-
 
 aggr_ordered(S) :- var(S),!.
 aggr_ordered({}) :- !.
-aggr_ordered(S) :- 
+aggr_ordered(S) :-
        S = R with X,
-       in_order(X,R), 
+       in_order(X,R),
        aggr_ordered(R).
 
 in_order(_A,S) :- var(S),!.
 in_order(_A,{}) :- !.
-in_order(A,S) :-  
+in_order(A,S) :-
        S = _R with _B,
        var(A), !.
-in_order(A,S) :-  
+in_order(A,S) :-
        S = R with B,
        var(B), in_order(A,R),!.
-in_order(A,S) :-  
+in_order(A,S) :-
        S = _R with B,
        A @=< B.
 
 force_bounds_values(A,B) :-
-       solve_FD(A =< B),     
+       solve_FD(A =< B),
        (var(A),!, labeling(A) ; true),
        (var(B),!, labeling(B) ; true).
 
-  
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%  "Built-in" predicates
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1032,7 +1032,7 @@ sys(@<,2).
 sys(@>,2).
 sys(@=<,2).
 sys(@>=,2).
-%%********* list to be completed!!********* 
+%%********* list to be completed!!*********
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% {log} built-in predicates
 
@@ -1047,57 +1047,57 @@ sys_special(read(T),C) :-              %% read
 sys_special(assert(Clause),[]):-       %% assert
       !,setassert(Clause).
 
-sys_special(consult_lib,[]):-          %% stores clauses contained in the {log} library file into                       
-      !,rem_clause(lib), rem_clause(tmp(lib)),       %% the current program in the library ctxt   
-      setlog_open('setloglib.slog',read,FileStream), %% (removing all clauses possibly stored 
-      switch_ctxt(lib,OldCtxt),                      %% in the same ctxt) 
+sys_special(consult_lib,[]):-          %% stores clauses contained in the {log} library file into
+      !,rem_clause(lib), rem_clause(tmp(lib)),       %% the current program in the library ctxt
+      setlog_open('setloglib.slog',read,FileStream), %% (removing all clauses possibly stored
+      switch_ctxt(lib,OldCtxt),                      %% in the same ctxt)
       read_loop_np(FileStream),
       switch_ctxt(OldCtxt,_),
-      close(FileStream). 
+      close(FileStream).
 
-sys_special(add_lib(File),[]):-        %% adds clauses contained in file F to the current 
+sys_special(add_lib(File),[]):-        %% adds clauses contained in file F to the current
       sys_special(add_lib(File,[])).
 
-sys_special(add_lib(File,Options),[]):-        %% adds clauses contained in file F to the current 
+sys_special(add_lib(File,Options),[]):-        %% adds clauses contained in file F to the current
       !, setlog_open(File,read,FileStream,Options),          %% program in the library ctxt (without
       switch_ctxt(lib,OldCtxt),                      %% removing existing clauses)
       read_loop_np(FileStream),
       switch_ctxt(OldCtxt,_),
-      close(FileStream). 
+      close(FileStream).
 
-sys_special(consult(File),[]):-        %% stores clauses contained in file F into                            
+sys_special(consult(File),[]):-        %% stores clauses contained in file F into
       !, setlog_open(File,read,FileStream),          %% the current program in the user ctxt
       write('consulting file '), write(File),        %% (removing all clauses possibly stored
       write(' ...'), nl,                             %% in the same ctxt)
       sys_special(abolish,_),
       read_loop(FileStream,1),
       write('file '), write(File), write(' consulted.'), nl,
-      close(FileStream). 
+      close(FileStream).
 
-sys_special(consult(File,mute),[]):-   %% consult using mute mode 
-      !, setlog_open(File,read,FileStream), 
+sys_special(consult(File,mute),[]):-   %% consult using mute mode
+      !, setlog_open(File,read,FileStream),
       sys_special(abolish,_),
       read_loop_np(FileStream),
-      close(FileStream). 
+      close(FileStream).
 
 sys_special(listing,[]):-              %% listing
       !,nl, list_all.
-          
+
 sys_special(abolish,[]):-              %% abolish
       !,rem_clause(usr),
       rem_clause(tmp(usr)).
 
 sys_special(abort,[]):-                %% abort
       !,nl, write('Execution aborted'), nl,
-      setlog. 
+      setlog.
 
 sys_special(help,[]):- !, h(setlog).   %% help
-sys_special(h(X),[]):- !, h(X). 
+sys_special(h(X),[]):- !, h(X).
 
 sys_special(halt,[]):-                 %% halt
-%     confirm, !, 
-      abort.     
-% sys_special(halt,[]). 
+%     confirm, !,
+      abort.
+% sys_special(halt,[]).
 
 sys_special(time(G,T),C):-             %% time
       statistics(runtime,_),
@@ -1113,27 +1113,27 @@ consult_mute(File) :-                    %% like setlog(consult(File),_)
       setlog_open(File,read,FileStream), %% but no message is sent to the std output
       sys_special(abolish,_),
       read_loop_np(FileStream),
-      close(FileStream). 
+      close(FileStream).
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% auxiliary predicates for sys_special/2
 
-setlog_read(Term) :- 
-      on_exception(Msg,read(Term),syntax_error_msg(Msg)).   
+setlog_read(Term) :-
+      on_exception(Msg,read(Term),syntax_error_msg(Msg)).
 
-setlog_open(File,Mode,Stream,Options) :- 
-      mk_file_name(File,FullName),       
-      on_exception(Msg,open(FullName,Mode,Stream,Options),existence_error_msg(Msg)).    
+setlog_open(File,Mode,Stream,Options) :-
+      mk_file_name(File,FullName),
+      on_exception(Msg,open(FullName,Mode,Stream,Options),existence_error_msg(Msg)).
 
 setlog_open(File,Mode,Stream) :- setlog_open(File,Mode,Stream,[]).
 
 existence_error_msg(Text) :-
-      write('Existence error:'), nl,    
+      write('Existence error:'), nl,
       write('file '), write(Text), write(' does not exist'), nl,
       fail.
 
-rem_clause(Ctxt):-              
-      retract(isetlog(_,Ctxt)), 
-      fail. 
+rem_clause(Ctxt):-
+      retract(isetlog(_,Ctxt)),
+      fail.
 rem_clause(_).
 
 confirm :-
@@ -1142,7 +1142,7 @@ confirm :-
       C == 121,
       nl, write('Bye, bye. See you later').
 
-mk_file_name(F,FullName) :-             
+mk_file_name(F,FullName) :-
       path(Dir),
       name(Dir,DirList),
       name(F,FList),
@@ -1154,53 +1154,53 @@ mk_file_name(F,FullName) :-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%               
-%%%%%%%%%%%%%% Program storing and printing %%%%%%%%%%%%%%%%%               
-%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%               
+%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%% Program storing and printing %%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%   Consulting and storing {log} clauses  
+%%%%%%%%   Consulting and storing {log} clauses
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 context(usr).
 
 read_loop_np(FileStream):-
-       setlog_read(FileStream,Clause), 
-       Clause \== end_of_file,!, 
-       assert_or_solve(Clause),   
+       setlog_read(FileStream,Clause),
+       Clause \== end_of_file,!,
+       assert_or_solve(Clause),
        read_loop_np(FileStream).
 read_loop_np(_).
 
 read_loop(FileStream,N):-
-       setlog_read(FileStream,Clause), 
-       Clause \== end_of_file,!, 
+       setlog_read(FileStream,Clause),
+       Clause \== end_of_file,!,
        assert_or_solve(Clause,N),
        N1 is N + 1,
        read_loop(FileStream,N1).
 read_loop(_,_).
 
-setlog_read(Stream,Term) :- 
-       on_exception(Msg,read(Stream,Term),syntax_error_cont_msg(Msg)).   
+setlog_read(Stream,Term) :-
+       on_exception(Msg,read(Stream,Term),syntax_error_cont_msg(Msg)).
 
-assert_or_solve((:- Goal)):-!,  
+assert_or_solve((:- Goal)):-!,
        solve(Goal,_).
-assert_or_solve(Clause):- 
+assert_or_solve(Clause):-
        setassert(Clause).
 
 assert_or_solve((:- Goal),_):-!,
        solve(Goal,_).
-assert_or_solve(Clause,N):- 
+assert_or_solve(Clause,N):-
        setassert(Clause),
        write('Clause '), write(N), write(' stored'), nl.
 
-setassert(Clause):- 
+setassert(Clause):-
        context(Ctxt),
        setassert(Clause,Ctxt).
-setassert(Clause,Ctxt):- 
+setassert(Clause,Ctxt):-
        transform_clause(Clause,BaseClause),
        assert(setlog:isetlog(BaseClause,Ctxt)).
 
@@ -1209,7 +1209,7 @@ switch_ctxt(NewCtxt,OldCtxt) :-
        assert(context(NewCtxt)).
 
 tmp_switch_ctxt(OldCtxt) :-
-       context(OldCtxt), 
+       context(OldCtxt),
        functor(OldCtxt,tmp,_),!.
 tmp_switch_ctxt(OldCtxt) :-
        retract(context(OldCtxt)),
@@ -1217,7 +1217,7 @@ tmp_switch_ctxt(OldCtxt) :-
        assert(context(NewCtxt)).
 
 syntax_error_cont_msg(Text) :-
-       write('Syntax error:'), nl,      
+       write('Syntax error:'), nl,
        write(Text), nl.
 
 
@@ -1225,11 +1225,11 @@ syntax_error_cont_msg(Text) :-
 %%%%%%%%   Program listing
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-list_all :-                            
-      isetlog((H :- B),usr), 
-      postproc(H,Hnew), write(Hnew), 
+list_all :-
+      isetlog((H :- B),usr),
+      postproc(H,Hnew), write(Hnew),
       write_body(B).
-list_all. 
+list_all.
 
 write_body(true) :-
       !, write('.'),nl,nl,
@@ -1238,24 +1238,24 @@ write_body(type(_) & true) :-
       !, write('.'),nl,nl,
       fail.
 write_body(B) :-
-      write((:-)), nl, 
+      write((:-)), nl,
       write('   '), postproc(B,Bnew), write_atoms(Bnew), write('.'),nl,nl,
       fail.
 
 write_atoms(B & true) :-
       !, write_atom(B).
-write_atoms(B1 & B2) :- 
-      write_atom(B1), 
-      (B2 = (type(_) & _), ! 
+write_atoms(B1 & B2) :-
+      write_atom(B1),
+      (B2 = (type(_) & _), !
       ;
-       write(' & '), nl, write('   ')), 
+       write(' & '), nl, write('   ')),
       write_atoms(B2).
 
-write_atom(A) :-    
+write_atom(A) :-
       var(A),!,
       write(A).
-write_atom(ruq_call(Aggr,Goal_name,FV)) :- 
-      !, write('forall('),write(X),write(' in '),write(Aggr),write(','), 
+write_atom(ruq_call(Aggr,Goal_name,FV)) :-
+      !, write('forall('),write(X),write(' in '),write(Aggr),write(','),
       RUQ_body_pred =.. [Goal_name,X|FV], isetlog((RUQ_body_pred :- RUQ_body),_),
       extract_vars(RUQ_body,Vars),
       remove_list([X|FV],Vars,LocalVars),
@@ -1264,19 +1264,19 @@ write_atom(ruq_call(Aggr,Goal_name,FV)) :-
        write_atoms(RUQ_bodyNew), write(')')
        ;
        write('exists('),write(LocalVars),write(','),
-       write_atoms(RUQ_bodyNew), write('))') 
+       write_atoms(RUQ_bodyNew), write('))')
       ).
 write_atom(type(_)) :- !.
 write_atom(neg A) :- !,
-      write('neg '), 
+      write('neg '),
       write('('), write_atoms(A), write(')').
 write_atom(naf A) :- !,
-      write('naf '), 
+      write('naf '),
       write('('), write_atoms(A), write(')').
 write_atom(call(A)) :- !,
       write(call),
       write('('), write_atoms(A), write(')').
-write_atom(call(A,C)) :- !,     
+write_atom(call(A,C)) :- !,
       write(call),
       write('('), write_atoms(A),write(','),write(C),write(')').
 write_atom(solve(A)) :- !,
@@ -1295,17 +1295,17 @@ write_atom((A1 or A2)) :- !,
       write('('), write_atoms(A1),
       write(' or '),
       write_atoms(A2), write(')').
-write_atom(B) :- 
+write_atom(B) :-
       write(B).
 
-               
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%               
-%%%%%%%%%%%%%% The {log] Constraint Solver  %%%%%%%%%%%%%%%%%               
-%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%               
+%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%% The {log] Constraint Solver  %%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1326,68 +1326,68 @@ write_atom(B) :-
 %%%%%%%%%%%%%%%%%%% Atomic constraints %%%%%%%%%%%%%%%%%%%%%%
 
 atomic_constr(_ nin _) :-!.
-atomic_constr(_ in _) :-!. 
-atomic_constr(_ neq _) :-!.  
-atomic_constr(_ = _) :-!.      
+atomic_constr(_ in _) :-!.
+atomic_constr(_ neq _) :-!.
+atomic_constr(_ = _) :-!.
 atomic_constr(type(_)) :-!.
 atomic_constr(set(_)) :-!.
-atomic_constr(integer(_)) :-!.        
+atomic_constr(integer(_)) :-!.
 atomic_constr(delay(_,_)) :-!.
 atomic_constr(un(_,_,_)) :-!.
-atomic_constr(subset(_,_)) :-!.  
+atomic_constr(subset(_,_)) :-!.
 atomic_constr(disj(_,_)) :-!.
-atomic_constr(inters(_,_,_)) :-!.   
-atomic_constr(ssubset(_,_)) :-!.  
-
-atomic_constr(size(_,_)) :-!.   
-atomic_constr(sum(_,_)) :-!.  
-atomic_constr(smin(_,_)) :-!.             
-atomic_constr(smax(_,_)) :-!.  
-        
-atomic_constr(ninteger(_)) :-!.        
+atomic_constr(inters(_,_,_)) :-!.
+atomic_constr(ssubset(_,_)) :-!.
+
+atomic_constr(size(_,_)) :-!.
+atomic_constr(sum(_,_)) :-!.
+atomic_constr(smin(_,_)) :-!.
+atomic_constr(smax(_,_)) :-!.
+
+atomic_constr(ninteger(_)) :-!.
 atomic_constr(bag(_)) :-!.
 atomic_constr(list(_)) :-!.
 atomic_constr(nun(_,_,_)) :-!.
 atomic_constr(ndisj(_,_)) :-!.
-atomic_constr(solved(_,_,_,_)) :-!.   
-
-atomic_constr(_ is _) :-!.     
-atomic_constr(_ =< _) :-!.      
-atomic_constr(_ < _) :-!.       
-atomic_constr(_ >= _) :-!.      
-atomic_constr(_ > _) :-!. 
-      
+atomic_constr(solved(_,_,_,_)) :-!.
+
+atomic_constr(_ is _) :-!.
+atomic_constr(_ =< _) :-!.
+atomic_constr(_ < _) :-!.
+atomic_constr(_ >= _) :-!.
+atomic_constr(_ > _) :-!.
+
 atomic_constr(pfun(_)) :-!.
-atomic_constr(rel(_)) :-!.     
-atomic_constr(dom(_,_)) :-!. 
-atomic_constr(inv(_,_)) :-!.    
-atomic_constr(ran(_,_)) :-!. 
-atomic_constr(comp(_,_,_)) :-!.  
-atomic_constr(dompf(_,_)).             
-atomic_constr(comppf(_,_,_)) :-!. 
-atomic_constr(apply(_,_,_)) :-!.  
+atomic_constr(rel(_)) :-!.
+atomic_constr(dom(_,_)) :-!.
+atomic_constr(inv(_,_)) :-!.
+atomic_constr(ran(_,_)) :-!.
+atomic_constr(comp(_,_,_)) :-!.
+atomic_constr(dompf(_,_)).
+atomic_constr(comppf(_,_,_)) :-!.
+atomic_constr(apply(_,_,_)) :-!.
 atomic_constr(dres(_,_,_)) :-!.
 atomic_constr(drespf(_,_,_)) :-!.
-atomic_constr(rres(_,_,_)) :-!.  
+atomic_constr(rres(_,_,_)) :-!.
 atomic_constr(ndres(_,_,_)) :-!.
-atomic_constr(nrres(_,_,_)) :-!.  
+atomic_constr(nrres(_,_,_)) :-!.
 
 atomic_constr(npfun(_)) :-!.
 atomic_constr(nrel(_)) :-!.
 atomic_constr(npair(_)) :-!.
 
 
-%%%%%%%%%%%%  Constraint solver main procedure %%%%%%%%%%%%   
+%%%%%%%%%%%%  Constraint solver main procedure %%%%%%%%%%%%
 
 %%%% sat(+Constraint,-Solved_Form_Constraint,+final/non-final)
 
 sat([],[],_) :-!.
-sat(C,SFC,F):- 
+sat(C,SFC,F):-
       trace_in(C,1),
-      sat_step(C,NewC,R,F), 
+      sat_step(C,NewC,R,F),
       sat_cont(R,NewC,SFC,F).
 
-sat_cont(R,NewC,SFC,F) :-           %if R=='stop', then no rule has changed the CS in the last 
+sat_cont(R,NewC,SFC,F) :-           %if R=='stop', then no rule has changed the CS in the last
       R == stop,!,                  %call to 'sat_step' (-> fixpoint); otherwise, call 'sat' again
       trace_out(NewC,1),
 
@@ -1397,7 +1397,7 @@ sat_cont(R,NewC,SFC,F) :-           %if R=='stop', then no rule has changed the
       global_check(RedC,RedCS,RevC,F), %rewrite RedC to RevC
       (RevC == RedC,!,SFC=RevC,     %if RedC==RevC, then no rewriting has been applied:
        trace_out(NewC,2)
-       ;                            %RevC is the resulting constraint; 
+       ;                            %RevC is the resulting constraint;
        sat(RevC,SFC,F)              %otherwise, call 'sat' again
       ).
 sat_cont(_R,NewC,SFC,F) :-
@@ -1416,7 +1416,7 @@ norep_in_list_split([A|R],[A|S],cs(NeqCS,[A|OtherCS])) :-
 %DBG% sat_step(InC,_OutC,_Stop,_F):-   %only for debugging purposes
 %DBG%        write('    >>>>> sat step: '), write(InC),nl,
 %DBG%        get0(_),
-%DBG%        fail. 
+%DBG%        fail.
 
 sat_step([],[],stop,_F) :- !.
 %%%%%%%%%%%%%             % general constraints
@@ -1432,11 +1432,11 @@ sat_step([X in Y|R1],R2,Z,F):- !,
 %%%%%%%%%%%%%             % set/interval constraints
 sat_step([un(X,Y,W)|R1],R2,Z,F):- !,
           sat_un([un(X,Y,W)|R1],R2,Z,F).
-sat_step([subset(X,Y)|R1],R2,Z,F):- !,     
+sat_step([subset(X,Y)|R1],R2,Z,F):- !,
           sat_sub([subset(X,Y)|R1],R2,Z,F).
-sat_step([ssubset(X,Y)|R1],R2,Z,F):- !,     
+sat_step([ssubset(X,Y)|R1],R2,Z,F):- !,
           sat_ssub([ssubset(X,Y)|R1],R2,Z,F).
-sat_step([inters(X,Y,W)|R1],R2,Z,F):- !,     
+sat_step([inters(X,Y,W)|R1],R2,Z,F):- !,
           sat_inters([inters(X,Y,W)|R1],R2,Z,F).
 sat_step([disj(X,Y)|R1],R2,Z,F):- !,
           sat_disj([disj(X,Y)|R1],R2,Z,F).
@@ -1444,31 +1444,31 @@ sat_step([nun(X,Y,W)|R1],R2,Z,F):- !,
           sat_nun([nun(X,Y,W)|R1],R2,Z,F).
 sat_step([ndisj(X,Y)|R1],R2,Z,F):- !,
           sat_ndisj([ndisj(X,Y)|R1],R2,Z,F).
-sat_step([size(X,Y)|R1],R2,Z,F):- !,       
+sat_step([size(X,Y)|R1],R2,Z,F):- !,
           sat_size([size(X,Y)|R1],R2,Z,F).
-sat_step([sum(X,Y)|R1],R2,Z,F):- !,       
-          sat_sum([sum(X,Y)|R1],R2,Z,F).   
-sat_step([smin(X,Y)|R1],R2,Z,F):- !,         
-          sat_min([smin(X,Y)|R1],R2,Z,F).  
-sat_step([smax(X,Y)|R1],R2,Z,F):- !,            
-          sat_max([smax(X,Y)|R1],R2,Z,F).                      
+sat_step([sum(X,Y)|R1],R2,Z,F):- !,
+          sat_sum([sum(X,Y)|R1],R2,Z,F).
+sat_step([smin(X,Y)|R1],R2,Z,F):- !,
+          sat_min([smin(X,Y)|R1],R2,Z,F).
+sat_step([smax(X,Y)|R1],R2,Z,F):- !,
+          sat_max([smax(X,Y)|R1],R2,Z,F).
 %%%%%%%%%%%%%             % type constraints
-sat_step([set(X)|R1],R2,Z,F):- !,             
+sat_step([set(X)|R1],R2,Z,F):- !,
           sat_set([set(X)|R1],R2,Z,F).
-sat_step([integer(X)|R1],R2,Z,F):-!,            
+sat_step([integer(X)|R1],R2,Z,F):-!,
           sat_integer([integer(X)|R1],R2,Z,F).
-sat_step([type(TypeC)|R1],R2,Z,F):- !,          % type(C), where C is a type constraint, 
+sat_step([type(TypeC)|R1],R2,Z,F):- !,          % type(C), where C is a type constraint,
           sat_step([TypeC|R1],R2,Z,F).          % is dealt with as C, but it is not printed
 sat_step([bag(X)|R1],R2,Z,F):- !,               % when listing a program
           sat_bag([bag(X)|R1],R2,Z,F).
 sat_step([list(X)|R1],R2,Z,F):- !,
           sat_list([list(X)|R1],R2,Z,F).
-sat_step([ninteger(X)|R1],R2,Z,F):-!,            
+sat_step([ninteger(X)|R1],R2,Z,F):-!,
           sat_ninteger([ninteger(X)|R1],R2,Z,F).
 %%%%%%%%%%%%%             % control constraints
 sat_step([delay(A,G)|R1],R2,Z,F):- !,
           sat_delay([delay(A,G)|R1],R2,Z,F).
-sat_step([solved(C,G,Lev,Mode)|R1],R2,Z,F):- !,         % "solved" constraints: used to avoid 
+sat_step([solved(C,G,Lev,Mode)|R1],R2,Z,F):- !,         % "solved" constraints: used to avoid
           sat_solved([solved(C,G,Lev,Mode)|R1],R2,Z,F). % repeated additions of the same constraints
 %%%%%%%%%%%%%             % arithmetic constraints
 sat_step([X is Y|R1],R2,Z,F):-                  % ris set grouping
@@ -1478,25 +1478,25 @@ sat_step([X is Y|R1],R2,Z,F):-                  % ris set grouping
 sat_step([X is Y|R1],R2,Z,F):- !,               % integer equality
           sat_eeq([X is Y|R1],R2,Z,F).
 sat_step([C|R1],R2,Z,F):-                       % integer comparison relations
-          C =.. [OP,X,Y], 
+          C =.. [OP,X,Y],
           member(OP,['=<','<','>=','>']),!,
           sat_crel([[OP,X,Y]|R1],R2,Z,F).
 
 %%%%%%%%%%%%%             % binary relation and partial function constraints
-sat_step([rel(X)|R1],R2,Z,F):- !,               
-          sat_rel([rel(X)|R1],R2,Z,F).  
-sat_step([pfun(X)|R1],R2,Z,F):- !,               
+sat_step([rel(X)|R1],R2,Z,F):- !,
+          sat_rel([rel(X)|R1],R2,Z,F).
+sat_step([pfun(X)|R1],R2,Z,F):- !,
           sat_pfun([pfun(X)|R1],R2,Z,F).
 sat_step([inv(X,Y)|R1],R2,Z,F):- !,
           sat_inv([inv(X,Y)|R1],R2,Z,F).
 sat_step([dom(X,Y)|R1],R2,Z,F):- !,
           sat_dom([dom(X,Y)|R1],R2,Z,F).
 sat_step([dompf(R,A)|R1],R2,Z,F):- !,
-          sat_dompf([dompf(R,A)|R1],R2,Z,F).       
+          sat_dompf([dompf(R,A)|R1],R2,Z,F).
 sat_step([comp(R,S,T)|R1],R2,Z,F):- !,
           sat_comp([comp(R,S,T)|R1],R2,Z,F).
 sat_step([comppf(R,S,T)|R1],R2,Z,F):- !,
-          sat_comppf([comppf(R,S,T)|R1],R2,Z,F).   
+          sat_comppf([comppf(R,S,T)|R1],R2,Z,F).
 sat_step([ran(X,Y)|R1],R2,Z,F):- !,
           sat_ran([ran(X,Y)|R1],R2,Z,F).
 sat_step([dres(A,R,S)|R1],R2,Z,F):- !,
@@ -1512,21 +1512,21 @@ sat_step([nrres(A,R,S)|R1],R2,Z,F):- !,
 sat_step([apply(S,X,Y)|R1],R2,Z,F):- !,
           sat_apply([apply(S,X,Y)|R1],R2,Z,F).
 
-sat_step([npfun(X)|R1],R2,Z,F):- !,               
+sat_step([npfun(X)|R1],R2,Z,F):- !,
           sat_npfun([npfun(X)|R1],R2,Z,F).
-sat_step([nrel(X)|R1],R2,Z,F):- !,               
+sat_step([nrel(X)|R1],R2,Z,F):- !,
           sat_nrel([nrel(X)|R1],R2,Z,F).
-sat_step([npair(X)|R1],R2,Z,F):- !,               
+sat_step([npair(X)|R1],R2,Z,F):- !,
           sat_npair([npair(X)|R1],R2,Z,F).
 
 %%%%%%%%%%%%%%%%%%%% constraint solving tracing
 
 trace_in(C,L) :-
       trace(sat),!,
-      write('>>> Entering Level '), write(L),nl, 
+      write('>>> Entering Level '), write(L),nl,
       write('>>> Input constraint: '), write(C), nl,
       write('Press return to continue '), nl,
-      get0(_). 
+      get0(_).
 trace_in(_,_).
 
 trace_out(_C,L) :-
@@ -1540,17 +1540,17 @@ trace_irules(Rule) :-
       trace(irules),!,
       write('\n>>> Using inference rule '), write(Rule),nl.
 trace_irules(_).
-   
+
 trace_firules(Rule) :-
       trace(irules),!,
       write('\n>>> Using filtering inference rule '), write(Rule),nl.
 trace_firules(_).
-  
+
 trace_ffrules(Rule) :-
       trace(irules),!,
       write('\n>>> Using filtering fail rule '), write(Rule),nl.
 trace_ffrules(_).
- 
+
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%      Level 1     %%%%%%%%%%%%%%%%%%%%%%
@@ -1558,93 +1558,93 @@ trace_ffrules(_).
 
 
 %%%%%%%%%%%%
-%%%%%%%%%%%% Rewriting rules for general constraints %%%%%%%%%%%%%              
+%%%%%%%%%%%% Rewriting rules for general constraints %%%%%%%%%%%%%
 %%%%%%%%%%%%
 
 %%%%%%%%%%%%%%%%%%%%%% equality (=/2)
 
-sat_eq([T1 = T2|R1],[T1 = T2|R2],Stop,nf):-     % delayed until final_sat is called  
+sat_eq([T1 = T2|R1],[T1 = T2|R2],Stop,nf):-     % delayed until final_sat is called
         nonvar(T1), T1 = int(A,B), var(A), var(B),
-        nonvar(T2), is_empty(T2),!,                        
-        sat_step(R1,R2,Stop,nf).                   
-sat_eq([T1 = T2|R1],[T2 = T1|R2],Stop,nf):-     % delayed until final_sat is called 
+        nonvar(T2), is_empty(T2),!,
+        sat_step(R1,R2,Stop,nf).
+sat_eq([T1 = T2|R1],[T2 = T1|R2],Stop,nf):-     % delayed until final_sat is called
         nonvar(T2), T2 = int(A,B), var(A), var(B),
-        nonvar(T1), is_empty(T1),!,                        
-        sat_step(R1,R2,Stop,nf).                   
- 
+        nonvar(T1), is_empty(T1),!,
+        sat_step(R1,R2,Stop,nf).
+
 sat_eq([T1 = T2|R1],R2,c,F):-                   % X = t or t = X
         (var(T1),! ; var(T2)),!,
         sunify(T1,T2,C),
-        append(C,R1,R3), 
-        sat_step(R3,R2,_,F).  
-sat_eq([T1 = T2|R1],R2,c,F):-  
+        append(C,R1,R3),
+        sat_step(R3,R2,_,F).
+sat_eq([T1 = T2|R1],R2,c,F):-
         \+is_ris(T1,ris(_,_,_,_,_)),
         \+is_ris(T2,ris(_,_,_,_,_)),
         sunify(T1,T2,C),
-        append(C,R1,R3), 
+        append(C,R1,R3),
         sat_step(R3,R2,_,F).
-                   
+
 sat_eq([T1 = T2|R1],R2,c,F) :-                  % t = ris(...) --> ris(...) = t   (t not ris-term)
         nonvar(T1), \+is_ris(T1,ris(_,_,_,_,_)),
         nonvar(T2), is_ris(T2,ris(_,_,_,_,_)),!,
-        sat_eq([T2 = T1|R1],R2,_,F).                        
+        sat_eq([T2 = T1|R1],R2,_,F).
 sat_eq([T1 = T2|R1],R2,c,F):-                   % ris(V,{},F,P) = T --> T={}
         nonvar(T1), is_ris(T1,ris(_,Dom,_,_,_)),
         nonvar(Dom), is_empty(Dom),!,
-        sunify(T2,{},C), append(C,R1,R3), 
+        sunify(T2,{},C), append(C,R1,R3),
         sat_step(R3,R2,_,F).
-sat_eq([T1 = E|R1],[T1 = E|R2],Stop,F):-    
+sat_eq([T1 = E|R1],[T1 = E|R2],Stop,F):-
         nonvar(T1), is_ris(T1,ris(_,Dom,_,_,_)),
         var(Dom), nonvar(E), is_empty(E),!,     % ris(V,D,F,P) = {} --> irreducible   (var(D))
         sat_step(R1,R2,Stop,F).
-sat_eq([T1 = E |R1],R2,c,F):-                   % ris(V,{...},F,P) = {}    
+sat_eq([T1 = E |R1],R2,c,F):-                   % ris(V,{...},F,P) = {}
         nonvar(T1), is_ris(T1,ris(LV,Dom,Fl,P,PP)), nonvar(LV), LV=[X0|V],
-        nonvar(Dom), first_rest(Dom,X,D),             
+        nonvar(Dom), first_rest(Dom,X,D),
         nonvar(E), is_empty(E),!,
         chvar([X0|V],[],Vars,Fl,[],VarsNew,FlNew),
-        find_corr(X0,X,Vars,VarsNew),    
+        find_corr(X0,X,Vars,VarsNew),
         negate(FlNew,NegFl),
         mk_atomic_constraint(NegFl,NegFlD),
-        sat_step([NegFlD,ris([X0|V],D,Fl,P,PP) = E|R1],R2,_,F).                     
-sat_eq([T1 = S |R1],R2,c,F):-                   % ris(V,{...},F,P) = {...}   
+        sat_step([NegFlD,ris([X0|V],D,Fl,P,PP) = E|R1],R2,_,F).
+sat_eq([T1 = S |R1],R2,c,F):-                   % ris(V,{...},F,P) = {...}
         nonvar(T1), is_ris(T1,ris(LV,Dom,Fl,P,PP)), nonvar(LV), LV=[X0|V],
-        nonvar(Dom), first_rest(Dom,X,D),     
+        nonvar(Dom), first_rest(Dom,X,D),
         nonvar(S), first_rest(S,_,_),!,
         chvar([X0|V],[],FVars,[Fl,P,PP],[],FVarsNew,[FlNew,PNew,PPNew]),
-        find_corr(X0,X,FVars,FVarsNew), 
-        mk_atomic_constraint(PPNew,PPNewD), 
+        find_corr(X0,X,FVars,FVarsNew),
+        mk_atomic_constraint(PPNew,PPNewD),
        (
         solve_expression(Z,PNew),
         mk_atomic_constraint(FlNew,FlNewD),
-        sat_step([FlNewD,PPNewD,ris([X0|V],D,Fl,P,PP) with Z = S |R1],R2,_,F)                         
+        sat_step([FlNewD,PPNewD,ris([X0|V],D,Fl,P,PP) with Z = S |R1],R2,_,F)
        ;
         negate(FlNew,NegFl),
         mk_atomic_constraint(NegFl,NegFlD),
-        sat_step([NegFlD,PPNewD,ris([X0|V],D,Fl,P,PP)=S |R1],R2,_,F)   
-       ).                      
+        sat_step([NegFlD,PPNewD,ris([X0|V],D,Fl,P,PP)=S |R1],R2,_,F)
+       ).
 sat_eq([T1 = S|R1],R2,c,F):-                    % ris(V,D,F,P) = {...}   (var(D))
         nonvar(T1), is_ris(T1,ris(LV,Dom,Fl,P,PP)), nonvar(LV), LV=[X0|V],
-        var(Dom), nonvar(S), first_rest(S,X,A),!,  
+        var(Dom), nonvar(S), first_rest(S,X,A),!,
         Dom = B with Y,
         chvar([X0|V],[],Vars,[Fl,P,PP],[],VarsNew,[FlNew,PNew,PPNew]),
-        find_corr(X0,Y,Vars,VarsNew), 
+        find_corr(X0,Y,Vars,VarsNew),
         solve_expression(Z,PNew),
         mk_atomic_constraint(FlNew,FlNewD),
         mk_atomic_constraint(PPNew,PPNewD),
-        sat_step([FlNewD,Z=X,PPNewD,ris([X0|V],B,Fl,P,PP)=A |R1],R2,_,F).  
-sat_eq([T1 = S|R1],[T1 = S|R2],Stop,F):-    
-        nonvar(T1), is_ris(T1,ris(_,Dom,_,_,_)), 
+        sat_step([FlNewD,Z=X,PPNewD,ris([X0|V],B,Fl,P,PP)=A |R1],R2,_,F).
+sat_eq([T1 = S|R1],[T1 = S|R2],Stop,F):-
+        nonvar(T1), is_ris(T1,ris(_,Dom,_,_,_)),
         var(Dom), var(S),!,                     % ris(V,D,F,P) = S --> irreducible   (var(D), var(S))
-        sat_step(R1,R2,Stop,F).  
-sat_eq([T1 = T2 |R1],R2,c,F):-                  % ris(V1,{...},F1,P1) =  ris(V2,{...},F2,P2)  
+        sat_step(R1,R2,Stop,F).
+sat_eq([T1 = T2 |R1],R2,c,F):-                  % ris(V1,{...},F1,P1) =  ris(V2,{...},F2,P2)
         nonvar(T1), is_ris(T1,ris(LV1,Dom1,Fl1,P1,PP1)), nonvar(LV1), LV1=[X01|V1],
-        nonvar(Dom1), first_rest(Dom1,X,D1),         
+        nonvar(Dom1), first_rest(Dom1,X,D1),
         nonvar(T2), is_ris(T2,ris(LV2,Dom2,Fl2,P2,PP2)), nonvar(LV2), LV2=[X02|V2],
-        nonvar(Dom2), first_rest(Dom2,Y,D2),!, 
+        nonvar(Dom2), first_rest(Dom2,Y,D2),!,
         chvar([X01|V1],[],Vars1,[Fl1,P1,PP1],[],VarsNew1,[FlNew1,PNew1,PPNew1]),
-        find_corr(X01,X,Vars1,VarsNew1),  
+        find_corr(X01,X,Vars1,VarsNew1),
         chvar([X02|V2],[],Vars2,[Fl2,P2,PP2],[],VarsNew2,[FlNew2,PNew2,PPNew2]),
-        find_corr(X02,Y,Vars2,VarsNew2),  
+        find_corr(X02,Y,Vars2,VarsNew2),
         solve_expression(Z1,PNew1),
         solve_expression(Z2,PNew2),
         mk_atomic_constraint(PPNew1,PPNew1D),
@@ -1657,7 +1657,7 @@ sat_eq([T1 = T2 |R1],R2,c,F):-                  % ris(V1,{...},F1,P1) =  ris(V2,
        ;
         negate(FlNew1,NegFl1),
         mk_atomic_constraint(NegFl1,NegFl1D),
-        sat_step([NegFl1D,FlNew2,PPNew1D,PPNew2D, 
+        sat_step([NegFl1D,FlNew2,PPNew1D,PPNew2D,
                   ris([X01|V1],D1,Fl1,P1,PP1)=ris([X02|V2],D2,Fl2,P2,PP2) with Z2 |R1],R2,_,F)
        ;
         negate(FlNew2,NegFl2),
@@ -1669,24 +1669,24 @@ sat_eq([T1 = T2 |R1],R2,c,F):-                  % ris(V1,{...},F1,P1) =  ris(V2,
         negate(FlNew2,NegFl2),
         mk_atomic_constraint(NegFl1,NegFl1D),
         mk_atomic_constraint(NegFl2,NegFl2D),
-        sat_step([NegFl1D,NegFl2D,PPNew1D,PPNew2D, 
+        sat_step([NegFl1D,NegFl2D,PPNew1D,PPNew2D,
                   ris([X01|V1],D1,Fl1,P1,PP1)=ris([X02|V2],D2,Fl2,P2,PP2) |R1],R2,_,F)
        ).
 sat_eq([T2 = T1 |R1],R2,c,F):-                       % ris(V2,D2,F2,P2) = ris(V1,{...},F1,P1)    (var(D2))
         nonvar(T1), is_ris(T1,ris(_,Dom1,_,_,_)),
-        nonvar(Dom1), first_rest(Dom1,_X,_D1),         
+        nonvar(Dom1), first_rest(Dom1,_X,_D1),
         nonvar(T2), is_ris(T2,ris(_,Dom2,_,_,_)),
         var(Dom2),!,
         sat_eq([T1 = T2|R1],R2,_,F).
 sat_eq([T1 = T2 |R1],R2,c,F):-                       % ris(V1,{...},F1,P1) = ris(V2,D2,F2,P2)    (var(D2))
         nonvar(T1), is_ris(T1,ris(LV1,Dom1,Fl1,P1,PP1)), nonvar(LV1), LV1=[X01|V1],
-        nonvar(Dom1), first_rest(Dom1,X,D1),          
+        nonvar(Dom1), first_rest(Dom1,X,D1),
         nonvar(T2), is_ris(T2,ris(LV2,Dom2,Fl2,P2,PP2)), nonvar(LV2), LV2=[X02|V2],
         var(Dom2),!,
         chvar([X01|V1],[],Vars1,[Fl1,P1,PP1],[],VarsNew1,[FlNew1,PNew1,PPNew1]),
-        find_corr(X01,X,Vars1,VarsNew1),  
+        find_corr(X01,X,Vars1,VarsNew1),
         chvar([X02|V2],[],Vars2,[Fl2,P2,PP2],[],VarsNew2,[FlNew2,PNew2,PPNew2]),
-        find_corr(X02,Y,Vars2,VarsNew2),  
+        find_corr(X02,Y,Vars2,VarsNew2),
         solve_expression(Z1,PNew1),
         solve_expression(Z2,PNew2),
         mk_atomic_constraint(PPNew1,PPNew1D),
@@ -1695,12 +1695,12 @@ sat_eq([T1 = T2 |R1],R2,c,F):-                       % ris(V1,{...},F1,P1) = ris
          Dom2 = D2 with Y,
          mk_atomic_constraint(FlNew1,FlNew1D),
          mk_atomic_constraint(FlNew2,FlNew2D),
-         sat_step([FlNew1D,FlNew2D,Z1=Z2,PPNew1D,PPNew2D, 
+         sat_step([FlNew1D,FlNew2D,Z1=Z2,PPNew1D,PPNew2D,
                   ris([X01|V1],D1,Fl1,P1,PP1)=ris([X02|V2],D2,Fl2,P2,PP2) |R1],R2,_,F)
        ;
         negate(FlNew1,NegFl1),
         mk_atomic_constraint(NegFl1,NegFl1D),
-        sat_step([NegFl1D,PPNew1D,PPNew2D, 
+        sat_step([NegFl1D,PPNew1D,PPNew2D,
                   ris([X01|V1],D1,Fl1,P1,PP1)=ris([X02|V2],Dom2,Fl2,P2,PP2) |R1],R2,_,F)
        ).
 sat_eq([T1 = T2|R1],[T1 = T2|R2],Stop,F):-           % ris(V1,D1,F1,P1) = ris(V2,D2,F2,P2)  (var(D1),var(D2)) --> irreducible
@@ -1712,44 +1712,44 @@ sat_eq([T1 = T2|R1],[T1 = T2|R2],Stop,F):-           % ris(V1,D1,F1,P1) = ris(V2
 
 sat_riseq([X is RIS|R1],R2,c,F) :-                   % collecting all values satisfying the RIS
         nonvar(RIS), is_ris(RIS,ris(_,Dom,_,_,_)),   % if var(Dom) return the RIS itself
-        var(Dom), !, 
-        X = RIS,                   
+        var(Dom), !,
+        X = RIS,
         sat_step(R1,R2,_,F).
 sat_riseq([X is RIS|R1],R2,c,F):-                    % collecting all values satisfying the RIS
         final_sat([RIS = R with A],C),!,
         append(C,R1,R3),
-        X = RR with A,   
+        X = RR with A,
         sat_step([RR is R|R3],R2,_,F).
-sat_riseq([X is RIS|R1],R2,c,F):-                      
+sat_riseq([X is RIS|R1],R2,c,F):-
         final_sat([RIS = {}],C),
         append(C,R1,R3),
-        X = {},      
+        X = {},
         sat_step(R3,R2,_,F).
 
 is_ris(ris(LVars,Dom,Fl,P),ris(LVars,Dom,Fl,P,a=a)).           % ris/4 --> ris/5
 is_ris(ris(LVars,Dom,Fl,P,PP),ris(LVars,Dom,Fl,P,PP)).
 
 check_ris(ris(LVars,Dom,_Fl,_P,_PP)) :-
-       (nonvar(LVars), ground_elems(Dom),! 
+       (nonvar(LVars), ground_elems(Dom),!
         ;
         write('ERROR: is/2: Arguments are not sufficiently instantiated'),nl,
         fail).
 
-ground_elems(R) :- 
+ground_elems(R) :-
    var(R),!.
-ground_elems(R) :- 
+ground_elems(R) :-
    is_int(R,_,_),!.
 ground_elems({}) :- !.
-ground_elems(R with A) :- 
+ground_elems(R with A) :-
    ground(A), ground_elems(R).
 
-first_rest(R with X,X,R) :- !.   % first_rest(S,X,R): true if S is a not-empty set or a not-empty interval         
+first_rest(R with X,X,R) :- !.   % first_rest(S,X,R): true if S is a not-empty set or a not-empty interval
 first_rest(int(X,B),X,R) :-      % and X is its first component and R the remaining part
         integer(X), integer(B),
         X < B,!, X1 is X + 1,
         R = int(X1,B).
 first_rest(int(X,X),X,{}).
-                   
+
 negate(true,true) :- !.         % exists X,Y (not p(X,Y))
 negate(A=B,A neq B) :- !.
 negate(A neq B,A = B) :- !.
@@ -1761,11 +1761,11 @@ negate(A =< B,A > B) :- !.
 negate(A < B,A >= B) :- !.
 negate(disj(A,B),ndisj(A,B)) :- !.
 negate(ndisj(A,B),disj(A,B)) :- !.
-negate((B1 & B2),(NB1 or NB2)) :- !,   
-    negate(B1,NB1), 
+negate((B1 & B2),(NB1 or NB2)) :- !,
+    negate(B1,NB1),
     negate(B2,NB2).
-negate((B1 or B2),(NB1 & NB2)) :- !,   
-    negate(B1,NB1), 
+negate((B1 or B2),(NB1 & NB2)) :- !,
+    negate(B1,NB1),
     negate(B2,NB2).
 negate(A,NegA) :-               % user-defined predicates, with user-defined negative counterparts
     nonvar(A), functor(A,F,N),  % check if the negation of A is present; otherwise use the next clause
@@ -1776,18 +1776,18 @@ negate(A,NegA) :-               % user-defined predicates, without user-defined
     NegA = (naf A).
 
 solve_expression(X,E) :-
-     nonvar(E),   
+     nonvar(E),
      test_integer_expr(E),!,
      solve_FD(X is E).
 solve_expression(X,E) :-
      X = E.
 
-test_integer_expr(E) :-       % true if E is an integer expression       
+test_integer_expr(E) :-       % true if E is an integer expression
      on_exception(_Error,fd_eq(_X,E),fail).
 
 chvar(V,L1,L1,X,L2,L2,X) :-   %chvar(LocalVars,InitialVars,FinalVars,Term,InitialNewVars,FinalNewVars,NewTerm):
     var(X), notin(X,V), !.    %same as chvar/6 but it replaces only variables which odccur in the list 'LocalVars'
-chvar(_,L1,[X|L1],X,L2,[Y|L2],Y):-        %e.g. chvar([X,Y],[],f(X,g(Y,Z),Z,X),V1,[],T2,V2) --> 
+chvar(_,L1,[X|L1],X,L2,[Y|L2],Y):-        %e.g. chvar([X,Y],[],f(X,g(Y,Z),Z,X),V1,[],T2,V2) -->
     var(X), notin(X,L1), !.               % T2 = f(X',g(Y',Z),Z,X'), V1 = [Y,X], V2 = [Y',X']
 chvar(_,L1,L1,X,L2,L2,Y):-
     var(X), find_corr(X,Y,L1,L2),!.
@@ -1803,10 +1803,10 @@ chvar_all(V,L1,L1b,[A|R],L2,L2b,[B|S]):-
     chvar(V,L1,L1a,A,L2,L2a,B),
     chvar_all(V,L1a,L1b,R,L2a,L2b,S).
 
-mk_atomic_constraint(B,delay(BB,true)) :- 
+mk_atomic_constraint(B,delay(BB,true)) :-
     nonvar(B), B=(_B1 & _B2), !,
     conj_append(B,true,BB).
-mk_atomic_constraint(B,delay(BB,true)) :- 
+mk_atomic_constraint(B,delay(BB,true)) :-
     nonvar(B), B=(_B1 or _B2), !,
     conj_append(B,true,BB).
 mk_atomic_constraint(B,delay(B & true,true)) :-   % user-defned atomic predicates
@@ -1814,41 +1814,41 @@ mk_atomic_constraint(B,delay(B & true,true)) :-   % user-defned atomic predicate
 mk_atomic_constraint(B,B).                        % primitive atomic constraints
 
 
-%%%%%%%%%%%  Set/Multiset Unification Algorithm  %%%%%%%%%%%%               
-         
-sunify(X,Y,[]) :-                   % X = X  
-      var(X),var(Y),                                
+%%%%%%%%%%%  Set/Multiset Unification Algorithm  %%%%%%%%%%%%
+
+sunify(X,Y,[]) :-                   % X = X
+      var(X),var(Y),
       X == Y,!.
-sunify(X,Y,C) :-                    % X = t  
+sunify(X,Y,C) :-                    % X = t
       var(X),!,
       sunifyXt(X,Y,C).
-sunify(X,Y,C) :-                    % t = Y  
+sunify(X,Y,C) :-                    % t = Y
       var(Y),!,
-      sunify(Y,X,C).  
-sunify(T1,T2,C) :-                  % intervals 
+      sunify(Y,X,C).
+sunify(T1,T2,C) :-                  % intervals
       int_term(T1),int_term(T2),!,
-      intint_unify(T1,T2,C). 
+      intint_unify(T1,T2,C).
 sunify(T1,T2,C) :-                  % intervals
       int_term(T1), set_term(T2),!,
-      int_unify(T1,T2,C). 
+      int_unify(T1,T2,C).
 sunify(T1,T2,C) :-                  % intervals
       int_term(T2), set_term(T1),!,
-      int_unify(T2,T1,C). 
+      int_unify(T2,T1,C).
 
 sunify(T1,T2,[T1 = T2]) :-          % ris
-      nonvar(T1), is_ris(T1,ris(_,_,_,_,_)), 
+      nonvar(T1), is_ris(T1,ris(_,_,_,_,_)),
       nonvar(T2),!.
 sunify(T1,T2,[T1 = T2]) :-          % ris
       nonvar(T1),
       nonvar(T2), is_ris(T2,ris(_,_,_,_,_)),!.
 
-sunify(R,S,C) :-                    % {...} = {...}                     
+sunify(R,S,C) :-                    % {...} = {...}
       tail(R,TR),
       tail(S,TS),!,
       (samevar(TR,TS),!,
        stunify_samevar(R,S,TR,C)
        ;
-       stunify_ss(R,S,C) ). 
+       stunify_ss(R,S,C) ).
 sunify(X,Y,C) :-                    % bag unification +{...} = +{...}
       bag_tail(X,BX),
       bag_tail(Y,BY),!,
@@ -1856,37 +1856,37 @@ sunify(X,Y,C) :-                    % bag unification +{...} = +{...}
        stunify_bag_same(X,Y,C)
        ;
        stunify_bag(X,Y,C) ).
-sunify(X,Y,C) :-                    % f(...) = f(...) 
+sunify(X,Y,C) :-                    % f(...) = f(...)
       X=..[F|Ax],Y=..[F|Ay],!,
       sunifylist(Ax,Ay,C).
 
-sunifyXt(X,Y,[set(N)]) :-           % X = {...|X} 
+sunifyXt(X,Y,[set(N)]) :-           % X = {...|X}
       nonvar(Y),tail(Y,TY),samevar(X,TY),!,
       replace_tail(Y,N,NewY),
 %     occur_check(X,NewY),          % temporarily suppressed for efficiency reasons - uncomment to reactivate
-      X = NewY.               
-sunifyXt(X,Y,[]) :-                 % X = t  
+      X = NewY.
+sunifyXt(X,Y,[]) :-                 % X = t
 %     occur_check(X,Y),             % temporarily suppressed for efficiency reasons - uncomment to reactivate
       (is_fd_var(X),!,              % if X is a domain variable
        simple_integer_expr(Y)       % then Y must be a simple_integer_expr;
        ;                            % otherwise, it fails (without doing var. substitution)
        true),
-      X = Y.             
+      X = Y.
 
 %%%%%%%%%%% Set unification %%%%%%%%%%%%%%%%%
 %%  distinct tail vars.
 
 stunify_ss(R with X,S with Y,C) :-  % ground case: {...} = {...}
       ground(X), ground(Y),!,
-      (sunify(X,Y,C1),!, 
+      (sunify(X,Y,C1),!,
        stunify1_2_3(R,S,X,Y,C2),
        append(C1,C2,C)
       ;
-       sunify(R,N with Y,C1), 
+       sunify(R,N with Y,C1),
        sunify(S,N with X,C2),
        append(C1,C2,C3),
-       C = [set(N)|C3] ).       
-stunify_ss(R with X,S with Y,C) :-  % {...|X} = {...|Y}                        
+       C = [set(N)|C3] ).
+stunify_ss(R with X,S with Y,C) :-  % {...|X} = {...|Y}
       sunify(X,Y,C1),
       stunify1_2_3(R,S,X,Y,C2),
       append(C1,C2,C).
@@ -1894,17 +1894,17 @@ stunify_ss(R with X,S with Y,C) :-  % {...|X} = {...|Y} (permutativity)
       sunify(R,N with Y,C1),
       sunify(S,N with X,C2),
       append(C1,C2,C3),
-      C = [set(N)|C3].      
+      C = [set(N)|C3].
 
 stunify1_2_3(R,S,_,_,C) :-          % 1
       sunify(R,S,C).
 stunify1_2_3(R,S,_,Y,C) :-          % 2
       sunify(R,S with Y,C).
-stunify1_2_3(R,S,X,_,C) :-          % 3 
+stunify1_2_3(R,S,X,_,C) :-          % 3
       sunify(R with X,S,C).
 
 %%  same tail vars.
-stunify_samevar(R with X,S with Y,_TR,C):-   % {...|X} = {...|X} 
+stunify_samevar(R with X,S with Y,_TR,C):-   % {...|X} = {...|X}
       select_var(Z,S with Y,Rest),
       sunify(X,Z,C1),
       (sunify(R,Rest,C2)            % 1
@@ -1919,7 +1919,7 @@ stunify_samevar(R with X,S with Y,TR,C):-    % 4
       sunify(TR,N with X,C1),
       sunify(NewR,NewSS,C2),
       append(C1,C2,C3),
-      C = [set(N)|C3].      
+      C = [set(N)|C3].
 
 sunifylist([],[],[]).
 sunifylist([X|AX],[Y|AY],C):-
@@ -1930,18 +1930,18 @@ sunifylist([X|AX],[Y|AY],C):-
 %%%%%%%%%%% Interval unification %%%%%%%%%%%%%%%%%
 
 intint_unify(int(L,H),T2,[int(L,H) = T2]) :-            % int(A,B) = int(a,b), a > b (delayed)
-        var(L), var(H), is_empty_int(T2), !.    
+        var(L), var(H), is_empty_int(T2), !.
 intint_unify(T2,int(L,H),[int(L,H) = T2]) :-            % int(a,b) = int(A,B), a > b  (delayed)
-        var(L), var(H), is_empty_int(T2), !.  
+        var(L), var(H), is_empty_int(T2), !.
 intint_unify(int(L,H),T2,[integer(H), integer(L), H < L]) :-    % int(t1,t2) = int(a,b), a > b
-        is_empty_int(T2), !. 
+        is_empty_int(T2), !.
 intint_unify(T2,int(L,H),[integer(H), integer(L), H < L]) :-    % int(a,b) = int(t1,t2), a > b
-        is_empty_int(T2), !. 
+        is_empty_int(T2), !.
 
-intint_unify(int(L1,H1),int(L2,H2),[]) :-               % int(t1,t2) = int(a,b), a =< b                      
+intint_unify(int(L1,H1),int(L2,H2),[]) :-               % int(t1,t2) = int(a,b), a =< b
         ground(int(L2,H2)), L2 =< H2,!,
         L1 = L2, H1 = H2.
-intint_unify(int(L1,H1),int(L2,H2),[]) :-               % int(a,b) = int(t1,t2), a =< b, \+ground(int(t1,t2))            
+intint_unify(int(L1,H1),int(L2,H2),[]) :-               % int(a,b) = int(t1,t2), a =< b, \+ground(int(t1,t2))
         ground(int(L1,H1)), L1 =< H1,!,
         L1 = L2, H1 = H2.
 intint_unify(T1,T2,C) :-                                % int(t1,t2) = int(s1,s2)
@@ -1949,30 +1949,30 @@ intint_unify(T1,T2,C) :-                                % int(t1,t2) = int(s1,s2
         \+ground(T1), \+ground(T2), !,
         (C = [T1 neq {}, T2 neq {}, L1 = L2, H1 = H2]
          ;
-         C = [T1 = {}, T2 = {}] 
+         C = [T1 = {}, T2 = {}]
         ).
 
 int_unify(int(L,H),S2,[int(L,H) = S2]) :-            % int(A,B) = {}
-        var(L), var(H), nonvar(S2), S2 = {}, !.   
+        var(L), var(H), nonvar(S2), S2 = {}, !.
 int_unify(int(L,H),T2,C) :-                          % int(t1,t2) = {}
         T2 = {}, !,
-        C = [integer(H), integer(L), H < L]. 
-int_unify(T1,T2,C) :-                                % int(L,H) = {...} 
-        T2 = _ with _, T1 = int(A,B),          
+        C = [integer(H), integer(L), H < L].
+int_unify(T1,T2,C) :-                                % int(L,H) = {...}
+        T2 = _ with _, T1 = int(A,B),
         C = [smin(T2,A), smax(T2,B), size(T2,K), K is B-A+1].
 
-is_empty_int(int(A,B)) :-             
+is_empty_int(int(A,B)) :-
         integer(A), integer(B),
         A > B.
 
 %%%%%%%%%%% Multiset unification %%%%%%%%%%%%%%%%%
 
-stunify_bag_same(R mwith X, S mwith Y, C) :-   % +{...|X} = +{...|X} 
+stunify_bag_same(R mwith X, S mwith Y, C) :-   % +{...|X} = +{...|X}
         de_tail(R mwith X,ZX),
         de_tail(S mwith Y,ZY),
         sunify(ZX,ZY,C).
 
-stunify_bag(R mwith X, S mwith Y, C) :-        % +{...|X} = +{...|Y} 
+stunify_bag(R mwith X, S mwith Y, C) :-        % +{...|X} = +{...|Y}
         sunify(X,Y,C1),
         sunify(R,S,C2),
         append(C1,C2,C).
@@ -1980,7 +1980,7 @@ stunify_bag(R mwith X, S mwith Y,C) :-
         sunify(R, N mwith Y, C1),
         sunify(S, N mwith X, C2),
         append(C1,C2,C3),
-        C = [bag(N)|C3].        
+        C = [bag(N)|C3].
 
 %%%%%%%%%%%%%% Auxiliary predicates for unification
 
@@ -1995,51 +1995,51 @@ select_var(Z, R with Y, A with Y):-
 
 sat_neq([T1 neq T2|R1],R2,R,F):-                     % X neq t
          var(T1), nonvar(T2),!,
-         sat_neq_vn([T1 neq T2|R1],R2,R,F).                         
-sat_neq([T1 neq T2|R1],R2,c,F):-                     % t neq X  
+         sat_neq_vn([T1 neq T2|R1],R2,R,F).
+sat_neq([T1 neq T2|R1],R2,c,F):-                     % t neq X
          nonvar(T1), var(T2),!,
-         sat_neq([T2 neq T1|R1],R2,_,F).                         
+         sat_neq([T2 neq T1|R1],R2,_,F).
 sat_neq([T1 neq T2|R1],R2,R,F):-                     % X neq Y
          var(T1), var(T2),!,
-         sat_neq_vv([T1 neq T2|R1],R2,R,F).  
-sat_neq([T1 neq T2|R1],[T1 neq T2|R2],Stop,nf):-     % unbounded intervals int(A,B) neq {}    
+         sat_neq_vv([T1 neq T2|R1],R2,R,F).
+sat_neq([T1 neq T2|R1],[T1 neq T2|R2],Stop,nf):-     % unbounded intervals int(A,B) neq {}
          nonvar(T1), T1 = int(A,B), var(A), var(B),  % delayed until final_sat is called (--> Level 3)
-         nonvar(T2), is_empty(T2),!,                            
-         sat_step(R1,R2,Stop,nf).                   
+         nonvar(T2), is_empty(T2),!,
+         sat_step(R1,R2,Stop,nf).
 sat_neq([T1 neq T2|R1],R2,R,F):-                     % unbounded intervals int(A,B) neq t
          nonvar(T1), int_term(T1), \+ground(T1), !,
-         sat_neq_ui([T1 neq T2|R1],R2,R,F).  
-sat_neq([T1 neq T2|R1],R2,R,F):-                     % unbounded intervals t neq int(A,B) 
+         sat_neq_ui([T1 neq T2|R1],R2,R,F).
+sat_neq([T1 neq T2|R1],R2,R,F):-                     % unbounded intervals t neq int(A,B)
          nonvar(T2), int_term(T2), \+ground(T2), !,
-         sat_neq_ui([T2 neq T1|R1],R2,R,F).  
+         sat_neq_ui([T2 neq T1|R1],R2,R,F).
 sat_neq([T1 neq T2|R1],R2,R,F):-                     % bounded intervals int(a,b) neq t
          nonvar(T1), T1 = int(A,B),
          integer(A), integer(B),!,
-         sat_neq_i([T1 neq T2|R1],R2,R,F).   
+         sat_neq_i([T1 neq T2|R1],R2,R,F).
 sat_neq([T1 neq T2|R1],R2,R,F):-                     % bounded intervals t neq int(a,b)
          nonvar(T2), T2 = int(A,B),
          integer(A), integer(B),!,
-         sat_neq_i([T2 neq T1|R1],R2,R,F).   
+         sat_neq_i([T2 neq T1|R1],R2,R,F).
 
 sat_neq([T1 neq T2|R1],R2,c,F):-                     % ris: t neq ris(...) (t not ris-term)
          nonvar(T1), \+is_ris(T1,ris(_,_,_,_,_)),
          nonvar(T2), is_ris(T2,ris(_,_,_,_,_)),!,
-         sat_neq([T2 neq T1|R1],R2,_,F).                        
-sat_neq([T1 neq T2|R1],R2,R,F):-                     % ris: ris(...) neq t 
+         sat_neq([T2 neq T1|R1],R2,_,F).
+sat_neq([T1 neq T2|R1],R2,R,F):-                     % ris: ris(...) neq t
          nonvar(T1), is_ris(T1,ris(V,D,Fl,P,PP)),!,
-         sat_neq_ris([ris(V,D,Fl,P,PP) neq T2|R1],R2,R,F).                      
+         sat_neq_ris([ris(V,D,Fl,P,PP) neq T2|R1],R2,R,F).
 
 sat_neq([T1 neq T2|R1],R2,R,F):-                     % t1 neq t2
          nonvar(T1), nonvar(T2),!,
-         sat_neq_nn([T1 neq T2|R1],R2,R,F).   
+         sat_neq_nn([T1 neq T2|R1],R2,R,F).
                                                 % unbounded intervals
-sat_neq_ui([int(A,B) neq T2|R1],R2,c,F):-       % int(A,B) neq empty 
+sat_neq_ui([int(A,B) neq T2|R1],R2,c,F):-       % int(A,B) neq empty
          nonvar(T2), is_empty(T2),!,
-         sat_step([A =< B|R1],R2,_,F).   
+         sat_step([A =< B|R1],R2,_,F).
 sat_neq_ui([int(A,B) neq T2|R1],R2,c,F):-       % int(A,B) neq {S|R}
          nonvar(T2), T2 = _ with _, !,
          (sat_step([Z >= A, Z =< B, Z nin T2|R1],R2,_,F)
-         ;  
+         ;
           sat_step([Z < A, Z in T2|R1],R2,_,F)
          ;
           sat_step([Z > B, Z in T2|R1],R2,_,F)
@@ -2047,85 +2047,85 @@ sat_neq_ui([int(A,B) neq T2|R1],R2,c,F):-       % int(A,B) neq {S|R}
 sat_neq_ui([int(A,B) neq T2|R1],R2,c,F):-       % int(A,B) neq int(C,D)
          nonvar(T2), T2 = int(C,D), !,
          (sat_step([Z >= A, Z =< B, Z < C|R1],R2,_,F)
-         ;  
+         ;
           sat_step([Z >= A, Z =< B, Z > D|R1],R2,_,F)
-         ; 
+         ;
           sat_step([Z < A, Z >= C, Z =< D|R1],R2,_,F)
          ).
 sat_neq_ui([_T1 neq _T2|R1],R2,c,F):-           % int(A,B) neq t  (t non-set term)
-         sat_step(R1,R2,_,F).   
-                  
-sat_neq_vn([X neq T|R1],R2,c,F):-               % X neq t[X] 
+         sat_step(R1,R2,_,F).
+
+sat_neq_vn([X neq T|R1],R2,c,F):-               % X neq t[X]
          is_ker(T),
          occurs(X,T),!,
          sat_step(R1,R2,_,F).
-sat_neq_vn([X neq T|R1],R2,c,F):-               % X neq {... | X} 
+sat_neq_vn([X neq T|R1],R2,c,F):-               % X neq {... | X}
          T = _S with _T,
          tail(T,TS),samevar(X,TS),!,
-         split(T,_,L), 
+         split(T,_,L),
          member(Ti,L) ,
          sat_step([Ti nin X|R1],R2,_,F).
 sat_neq_vn([X neq T|R1],R2,c,F):-               % X neq {...,t[X],...}
          T = _S with _T,
          occurs(X,T),!,
          sat_step(R1,R2,_,F).
-sat_neq_vn([X neq T|R1],[X neq T|R2],Stop,F):-  % X neq t, t simple integer expr 
-         simple_integer_expr(T),   % to catch and handle type errors within {log} 
+sat_neq_vn([X neq T|R1],[X neq T|R2],Stop,F):-  % X neq t, t simple integer expr
+         simple_integer_expr(T),   % to catch and handle type errors within {log}
          is_fd_var(X), !,
          solve_FD(X neq T),
-         sat_step(R1,R2,Stop,F).  
+         sat_step(R1,R2,Stop,F).
 sat_neq_vn([C|R1],[C|R2],Stop,F):-              % X neq t (irreducible form)
          sat_step(R1,R2,Stop,F).
 
-sat_neq_vv([X neq Y|_],_,_,_F):-                % X neq X 
+sat_neq_vv([X neq Y|_],_,_,_F):-                % X neq X
          samevar(X,Y),!,fail.
-sat_neq_vv([X neq Y|R1],[X neq Y|R2],Stop,F):-  % X neq Y, X,Y domain variables  
+sat_neq_vv([X neq Y|R1],[X neq Y|R2],Stop,F):-  % X neq Y, X,Y domain variables
          is_fd_var(X),
          is_fd_var(Y),!,
          solve_FD(X neq Y),
          sat_step(R1,R2,Stop,F).
 sat_neq_vv([T1 neq T2|R1],R2,c,F):-             % Y neq X --> X neq Y
          T1 @> T2,!,
-         sat_step([T2 neq T1|R1],R2,_,F).                         
+         sat_step([T2 neq T1|R1],R2,_,F).
 sat_neq_vv([C|R1],[C|R2],Stop,F):-              % X neq Y (irreducible form)
          sat_step(R1,R2,Stop,F).
 
 sat_neq_i([T1 neq T2|_R1],_R2,_,_F):-           % int(a,b) neq empty
-         nonvar(T1), nonvar(T2), 
+         nonvar(T1), nonvar(T2),
          is_empty(T1),is_empty(T2),!, fail.
 sat_neq_i([T1 neq T2|R1],R2,c,F):-              % int(a,b) neq int(c,d)
-         is_int(T1,A1,_B1), is_int(T2,A2,_B2), 
+         is_int(T1,A1,_B1), is_int(T2,A2,_B2),
          A1 \== A2,!,
          sat_step(R1,R2,_,F).
 sat_neq_i([T1 neq T2|R1],R2,c,F):-              % int(a,b) neq int(c,d)
-         is_int(T1,_A1,B1), is_int(T2,_A2,B2), 
-         B1 \== B2,!, 
+         is_int(T1,_A1,B1), is_int(T2,_A2,B2),
+         B1 \== B2,!,
          sat_step(R1,R2,_,F).
 sat_neq_i([T1 neq T2|R1],R2,c,F):-              % int(a,b) neq {S|R} (special)
          set_length(T2,SetL),
          int_length(T1,IntL),
          SetL < IntL, !,
          sat_step(R1,R2,_,F).
-sat_neq_i([T1 neq T2|R1],R2,c,F):-              % int(a,b) neq {S|R} 
+sat_neq_i([T1 neq T2|R1],R2,c,F):-              % int(a,b) neq {S|R}
          nonvar(T2), T2 = _ with _, !,
          (sat_step([Z in T1, Z nin T2, integer(Z) | R1],R2,_,F)     % (i)
           ;
           sat_step([Z nin T1, Z in T2| R1],R2,_,F)                  % (ii)
          ).
 sat_neq_i([_T1 neq _T2|R1],R2,c,F):-            % int(a,b) neq t (t non-set term)
-         sat_step(R1,R2,_,F).   
+         sat_step(R1,R2,_,F).
 
 sat_neq_nn([F neq G|R1],R2,c,Fin):-             % ground case: t1 neq t2
          ground(F),ground(G),!,
          g_neq(F,G),
          sat_step(R1,R2,_,Fin).
-sat_neq_nn([F neq G|R1],R2,c,Fin):-             % t1 neq t2 
+sat_neq_nn([F neq G|R1],R2,c,Fin):-             % t1 neq t2
          functor(F,Fname,Far),functor(G,Gname,Gar),
          (Fname \== Gname ; Far \== Gar),!,
          sat_step(R1,R2,_,Fin).
-sat_neq_nn([F neq G|R1],R2,c,Fin):-             % t1 neq t2 
+sat_neq_nn([F neq G|R1],R2,c,Fin):-             % t1 neq t2
          functor(F,Fname,Far),functor(G,Gname,Gar),
-         Fname == Gname, Far == Gar, 
+         Fname == Gname, Far == Gar,
          Fname \== with, Fname \== mwith,
          F =.. [_|Flist], G =.. [_|Glist],!,
          memberall(A,B,Flist,Glist),
@@ -2137,17 +2137,17 @@ sat_neq_nn([T1 neq T2|R1],R2,c,F):-             % inequality between sets
          T1 = _S with _A, T2 = _R with _B,!,    % {A|S} neq {B|R} (ii)
          sat_step([Z in T2, Z nin T1 | R1],R2,_,F).
 
-%%%%%%%%%%%% multisets 
+%%%%%%%%%%%% multisets
 sat_neq_nn([T1 neq T2|R1],R2,c,F):-             % inequality between multisets
          nonvar(T1),nonvar(T2),                 % with the same tail variables
-         bag_tail(T1,TT1), bag_tail(T2,TT2), 
+         bag_tail(T1,TT1), bag_tail(T2,TT2),
          samevar(TT1,TT2),!,
          de_tail(T1,DT1), de_tail(T2,DT2),
          sat_step([DT1 neq DT2|R1],R2,_,F).
 sat_neq_nn([T1 neq T2|R1],R2,c,F):-             % inequality between multisets
          T1 = _S mwith A, T2 = R mwith B,       % with distinct tail variables
          sat_step([A neq B, A nin R| R1],R2,_,F).
-sat_neq_nn([T1 neq T2|R1],R2,c,F):-      
+sat_neq_nn([T1 neq T2|R1],R2,c,F):-
          T1 = _S mwith A, T2 = R mwith B,!,
          sunify(R mwith B, _N mwith A,C),
          append(C,R1,R3),
@@ -2159,39 +2159,39 @@ sat_neq_ris([T1 neq T2|_R1],_R2,c,_F):-          % ris(...) neq {}
         nonvar(T2), is_empty(T2),!,fail.
 sat_neq_ris([T1 neq T2|R1],R2,c,F):-             % ris(...) neq t
         nonvar(T1), is_ris(T1,ris(LV,D,Fl,P,PP)), nonvar(LV), LV=[X0|V],!,
-       (sat_step([Z in ris([X0|V],D,Fl,P,PP),Z nin T2|R1],R2,_,F)                         
+       (sat_step([Z in ris([X0|V],D,Fl,P,PP),Z nin T2|R1],R2,_,F)
        ;
-        sat_step([Z nin ris([X0|V],D,Fl,P,PP),Z in T2|R1],R2,_,F)   
-       ).                      
+        sat_step([Z nin ris([X0|V],D,Fl,P,PP),Z in T2|R1],R2,_,F)
+       ).
 
 
 %%%%%%%%%%%%
-%%%%%%%%%%%% Rewriting rules for arithmetic constraints %%%%%%%%%%%% 
-%%%%%%%%%%%%            
+%%%%%%%%%%%% Rewriting rules for arithmetic constraints %%%%%%%%%%%%
+%%%%%%%%%%%%
 
-sat_eeq([X is E|R1],R2,c,F):-        % integer equality (is/2)            
+sat_eeq([X is E|R1],R2,c,F):-        % integer equality (is/2)
         ground(E),!,
-        simple_arithm_expr(X),       % to catch type errors within {log} 
-        arithm_expr(E),           
+        simple_arithm_expr(X),       % to catch type errors within {log}
+        arithm_expr(E),
         X is E,
         sat_step(R1,R2,_,F).
-sat_eeq([X is E|R1],R2,c,F):-        % integer equality             
-        simple_integer_expr(X),      % to catch type errors within {log} 
-        integer_expr(E),           
+sat_eeq([X is E|R1],R2,c,F):-        % integer equality
+        simple_integer_expr(X),      % to catch type errors within {log}
+        integer_expr(E),
         solve_FD(X is E),
         allintvars(X is E,Intc),
         append(Intc,R1,Newc),
         sat_step(Newc,R2,_,F).
 
-sat_crel([[OP,E1,E2]|R1],R2,c,F):-   % integer comparison relations (=<,<,>=,>)                 
+sat_crel([[OP,E1,E2]|R1],R2,c,F):-   % integer comparison relations (=<,<,>=,>)
         ground(E1), ground(E2),!,
-        arithm_expr(E1),             % to catch type errors within {log} 
-        arithm_expr(E2), 
+        arithm_expr(E1),             % to catch type errors within {log}
+        arithm_expr(E2),
         Rel =.. [OP,E1,E2],
-        call(Rel),          
+        call(Rel),
         sat_step(R1,R2,_,F).
-sat_crel([[OP,E1,E2]|R1],R2,c,F):-                   
-        integer_expr(E1),            % to catch type errors within {log} 
+sat_crel([[OP,E1,E2]|R1],R2,c,F):-
+        integer_expr(E1),            % to catch type errors within {log}
         integer_expr(E2),
         Rel =.. [OP,E1,E2],
         solve_FD(Rel),
@@ -2200,9 +2200,9 @@ sat_crel([[OP,E1,E2]|R1],R2,c,F):-
         sat_step(Newc,R2,_,F).
 
 allintvars(E,Evars) :-     % true if E is an arithmetic expression and Evars
-    E =.. [_F|Args],       % is a list containing a contraint integer(X) for 
+    E =.. [_F|Args],       % is a list containing a contraint integer(X) for
     addint(Args,Evars).    % each variable X in E
-    
+
 addint([],[]):-!.
 addint([X|R],[integer(X)|Rvars]) :-
     var(X),!,
@@ -2215,85 +2215,85 @@ addint([E|R],Allvars) :-
 
 %%%%%%%%%%%%
 %%%%%%%%%%%% Rewriting rules for set/bag/list/interval constraints %%%%%%%%%%%%
-%%%%%%%%%%%%              
+%%%%%%%%%%%%
 
 %%%%%%%%%%%%%%%%%%%%%% membership (in/2)
 
-sat_in([T in I|R1],R2,R,F):-                         
+sat_in([T in I|R1],R2,R,F):-
          var(I),!,
-         sat_in_v([T in I|R1],R2,R,F).   
-sat_in([T in I|R1],R2,R,F):-                 % bounded interval: t in int(a,b)                         
+         sat_in_v([T in I|R1],R2,R,F).
+sat_in([T in I|R1],R2,R,F):-                 % bounded interval: t in int(a,b)
          nonvar(I), is_int(I,L,H),!,
-         sat_in_i([T in int(L,H)|R1],R2,R,F).                      
-sat_in([T in I|R1],R2,R,F):-                 % unbounded interval: t in int(A,B)         
+         sat_in_i([T in int(L,H)|R1],R2,R,F).
+sat_in([T in I|R1],R2,R,F):-                 % unbounded interval: t in int(A,B)
          nonvar(I), int_term(I),!,
-         sat_in_ui([T in I|R1],R2,R,F). 
+         sat_in_ui([T in I|R1],R2,R,F).
 
-sat_in([T in I|R1],R2,R,F):-                 % ris                              
+sat_in([T in I|R1],R2,R,F):-                 % ris
          nonvar(I), is_ris(I,ris(V,D,Fl,P,PP)),!,
-         sat_in_ris([T in ris(V,D,Fl,P,PP)|R1],R2,R,F).                      
+         sat_in_ris([T in ris(V,D,Fl,P,PP)|R1],R2,R,F).
 
-sat_in([T in I|R1],R2,R,F):-                 % extensional set/multiset/list;  t in {...}                  
+sat_in([T in I|R1],R2,R,F):-                 % extensional set/multiset/list;  t in {...}
          nonvar(I),!,
-         sat_in_s([T in I|R1],R2,R,F).                         
+         sat_in_s([T in I|R1],R2,R,F).
 
-sat_in_v([T in X|R1],R2,c,F):-               % t in X, set 
+sat_in_v([T in X|R1],R2,c,F):-               % t in X, set
          sunify(X,N with T,_),
          sat_step([set(N)|R1],R2,_,F).
 sat_in_v([T in X|R1],R2,c,F):-               % t in X, multiset
          sunify(X,N mwith T,_),
          sat_step([bag(N)|R1],R2,_,F).
-sat_in_v([T in X|R1],                        
-         [solved(T in X,(var(X),occur_check(X,T)),3,f),list(X)|R2],Stop,F):-  
+sat_in_v([T in X|R1],
+         [solved(T in X,(var(X),occur_check(X,T)),3,f),list(X)|R2],Stop,F):-
          occur_check(X,T),                   % t in X, list (irreducible form)
-         sat_step(R1,R2,Stop,F).  
-           
+         sat_step(R1,R2,Stop,F).
+
 sat_in_i([T in int(A,B)|R1],R2,c,F):-        % bounded interval: t in int(a,b)
-         simple_integer_expr(T),!,            
+         simple_integer_expr(T),!,
          solve_FD(T in int(A,B)),
-         sat_step([integer(T)|R1],R2,_,F).  
- 
+         sat_step([integer(T)|R1],R2,_,F).
+
 sat_in_ui([T in I|R1],R2,c,F):-              % unbounded interval: t in int(A,B)
-         simple_integer_expr(T),!,           % either A or B vars  
+         simple_integer_expr(T),!,           % either A or B vars
          I=int(A,B),
          solve_FD(T >= A),solve_FD(T =< B),
-         sat_step([integer(T)|R1],R2,_,F).  
+         sat_step([integer(T)|R1],R2,_,F).
 
-sat_in_s([T in Aggr|R1],R2,c,F):-            % ground set/multiset/list: t in {...} 
+sat_in_s([T in Aggr|R1],R2,c,F):-            % ground set/multiset/list: t in {...}
          ground(T), ground(Aggr),!,
-         g_member(T,Aggr), 
+         g_member(T,Aggr),
          sat_step(R1,R2,_,F).
-sat_in_s([T in Aggr|R1],R2,c,F):-            % non-ground set/multiset/list (case i): t in {...} 
+sat_in_s([T in Aggr|R1],R2,c,F):-            % non-ground set/multiset/list (case i): t in {...}
          aggr_comps(Aggr,A,_R),
-         sunify(A,T,C), 
-         append(C,R1,R3), 
+         sunify(A,T,C),
+         append(C,R1,R3),
          sat_step(R3,R2,_,F).
 sat_in_s([T in Aggr|R1],R2,c,F):-            % non-ground set/multiset/list (case ii): t in {...}
          aggr_comps(Aggr,_A,R),!,
          sat_step([T in R|R1],R2,_,F).
 
 sat_in_ris([X in ris([X0|V],D,Fl,P,PP)|R1],R2,c,F):-    % ris: X in ris{v,D,...)    (var(D))
-         var(D),!,  
+         var(D),!,
          chvar([X0|V],[],Vars,[Fl,P,PP],[],VarsNew,[FlNew,PNew,PPNew]),
-         find_corr(X0,Y,Vars,VarsNew), 
+         find_corr(X0,Y,Vars,VarsNew),
          solve_expression(Z,PNew),
-         X = Z,                                                   
+         X = Z,
          mk_atomic_constraint(PPNew,PPNewD),
         (
          FlNew = (D1 or D2),
-         D2 = (apply(this,XX,FF) & A),!,                            
+         D2 = (apply(this,XX,FF) & A),!,
          chvar([],_Vars,ris([X0|V],D,Fl,P,PP),[],_VarsNew,RisNew),
          FlNew1 = (D1 or (delay([XX,FF] in RisNew,a=b) & A)),
          mk_atomic_constraint(FlNew1,FlNewD)
          ;
          mk_atomic_constraint(FlNew,FlNewD)
         ),
-         sat_step([Y in D,set(D),FlNewD,PPNewD |R1],R2,_,F).   
+         sat_step([Y in D,set(D),FlNewD,PPNewD |R1],R2,_,F).
 
-sat_in_ris([X in ris([X0|V],Dom,Fl,P,PP)|R1],R2,c,F):-  % ris: X in ris{v,{...},...)   
-         nonvar(Dom), first_rest(Dom,Y,D),!,  
+sat_in_ris([X in ris([X0|V],Dom,Fl,P,PP)|R1],R2,c,F):-  % ris: X in ris{v,{...},...)
+         nonvar(Dom), first_rest(Dom,Y,D),!,
          chvar([X0|V],[],Vars,[Fl,P,PP],[],VarsNew,[FlNew,PNew,PPNew]),
-         find_corr(X0,Y,Vars,VarsNew), 
+         find_corr(X0,Y,Vars,VarsNew),
          solve_expression(Z,PNew),
          mk_atomic_constraint(FlNew,FlNewD),
          mk_atomic_constraint(PPNew,PPNewD),
@@ -2301,44 +2301,44 @@ sat_in_ris([X in ris([X0|V],Dom,Fl,P,PP)|R1],R2,c,F):-  % ris: X in ris{v,{...},
          ;
          negate(FlNew,NegFl),
          mk_atomic_constraint(NegFl,NegFlD),
-         sat_step([NegFlD,X in ris([X0|V],D,Fl,P,PP) |R1],R2,_,F) 
+         sat_step([NegFlD,X in ris([X0|V],D,Fl,P,PP) |R1],R2,_,F)
          ).
 
 %%%%%%%%%%%%%%%%%%%%%% non-membership (nin/2)
 
-sat_nin([T nin A|R1],R2,c,F):-              % ground set/multiset/list/interval: 
+sat_nin([T nin A|R1],R2,c,F):-              % ground set/multiset/list/interval:
         ground(T), ground(A),!,             % t nin {A|R} or t nin +{A|R} or t nin [A|R] or t nin int(a,b)
-        \+g_member(T,A), 
+        \+g_member(T,A),
         sat_step(R1,R2,_,F).
-sat_nin([T nin A|R1],R2,c,F):-              % t nin X, t[X] 
-        var(A), occurs(A,T),!,                          
+sat_nin([T nin A|R1],R2,c,F):-              % t nin X, t[X]
+        var(A), occurs(A,T),!,
         sat_step(R1,R2,_,F).
 sat_nin([T nin A|R1],[T nin A|R2],Stop,F):- % t nin X, irreducible form
-        var(A),!, 
+        var(A),!,
         sat_step(R1,R2,Stop,F).
-sat_nin([_T nin A|R1],R2,c,F):-             % empty set/multiset/list/bounded interval:  
+sat_nin([_T nin A|R1],R2,c,F):-             % empty set/multiset/list/bounded interval:
         nonvar(A), empty_aggr(A),!,         % t nin {}  or  t nin []  or  t nin int(a,b) with a>b
         sat_step(R1,R2,_,F).
 sat_nin([R nin I|R1],R2,c,F) :-             % unbouded interval: t nin int(A,B)
         nonvar(I), int_term(I),             %   (case i)
-        simple_integer_expr(R),                          
+        simple_integer_expr(R),
         I=int(S,_T),
         solve_FD(R + 1 =< S),
         sat_step([integer(R),integer(S)|R1], R2, _, F).
 
 sat_nin([X nin I|R1],[X nin I|R2],Stop,F):- % ris: X nin ris{v,D,...) (var(D)): irreducible
         nonvar(I), is_ris(I,ris(_,Dom,_,_,_)),
-        var(Dom), !, 
+        var(Dom), !,
         sat_step(R1,R2,Stop,F).
 sat_nin([_X nin I|R1],R2,c,F):-             % ris: X nin ris{v,{},...) -> true
         nonvar(I), is_ris(I,ris(_,Dom,_,_,_)),
-        nonvar(Dom), is_empty(Dom), !, 
+        nonvar(Dom), is_empty(Dom), !,
         sat_step(R1,R2,_,F).
-sat_nin([X nin I|R1],R2,c,F):-              % ris: X nin ris{v,{...},...)   
+sat_nin([X nin I|R1],R2,c,F):-              % ris: X nin ris{v,{...},...)
         nonvar(I), is_ris(I,ris(LV,Dom,Fl,P,PP)), nonvar(LV), LV=[X0|V],
-        nonvar(Dom), first_rest(Dom,Y,D),!,  
+        nonvar(Dom), first_rest(Dom,Y,D),!,
         chvar([X0|V],[],Vars,[Fl,P,PP],[],VarsNew,[FlNew,PNew,PPNew]),
-        find_corr(X0,Y,Vars,VarsNew), 
+        find_corr(X0,Y,Vars,VarsNew),
         solve_expression(Z,PNew),
         mk_atomic_constraint(FlNew,FlNewD),
         mk_atomic_constraint(PPNew,PPNewD),
@@ -2346,73 +2346,73 @@ sat_nin([X nin I|R1],R2,c,F):-              % ris: X nin ris{v,{...},...)
         ;
         negate(FlNew,NegFl),
         mk_atomic_constraint(NegFl,NegFlD),
-        sat_step([NegFlD,X nin ris([X0|V],D,Fl,P,PP) |R1],R2,_,F) 
+        sat_step([NegFlD,X nin ris([X0|V],D,Fl,P,PP) |R1],R2,_,F)
         ).
 
 sat_nin([R nin I|R1],R2,c,F) :-             %   (case ii)
         nonvar(I), int_term(I),
-        simple_integer_expr(R), 
-        I=int(_S,T),                         
+        simple_integer_expr(R),
+        I=int(_S,T),
         solve_FD(T + 1 =< R),
         sat_step([integer(R),integer(T)|R1], R2, _, F).
 sat_nin([R nin I|R1], R2, c, F) :-          %   (case iii)
-        nonvar(I), int_term(I),!,       
+        nonvar(I), int_term(I),!,
         sat_step([ninteger(R)|R1], R2, _, F).
-sat_nin([T1 nin A|R1],R2,c,F):-             % non-ground set/multiset/list:   
+sat_nin([T1 nin A|R1],R2,c,F):-             % non-ground set/multiset/list:
         nonvar(A), aggr_comps(A,T2,S),!,    % t nin {...} or t nin +{...} or t nin [...]
         sat_step([T1 neq T2,T1 nin S|R1],R2,_,F).
-sat_nin([_T nin A|R1],R2,c,F):-             % t nin a, a not a set neither an interval 
-        nonvar(A),                           
+sat_nin([_T nin A|R1],R2,c,F):-             % t nin a, a not a set neither an interval
+        nonvar(A),
         sat_step(R1,R2,_,F).
 
 
 %%%%%%%%%%%%
 %%%%%%%%%%%% Rewriting rules for set/interval constraints %%%%%%%%%%%%
-%%%%%%%%%%%%              
+%%%%%%%%%%%%
 
-%%%%%%%%%%%%%%%%%%%%%% subset (subset/2)  
+%%%%%%%%%%%%%%%%%%%%%% subset (subset/2)
 
-sat_sub([subset(S1,S2)|R1],R2,c,F):-                 % ground case: subset({X|R},S2)            
+sat_sub([subset(S1,S2)|R1],R2,c,F):-                 % ground case: subset({X|R},S2)
          ground(S1), ground(S2),
          set_term(S1), set_term(S2),!,
          g_subset(S1,S2),
          sat_step(R1,R2,_,F).
-sat_sub([subset(S1,I2)|R1],R2,c,F):-                 % subset(X,int(L,H))    
-         var(S1), nonvar(I2), is_int(I2,_,_),!,      
+sat_sub([subset(S1,I2)|R1],R2,c,F):-                 % subset(X,int(L,H))
+         var(S1), nonvar(I2), is_int(I2,_,_),!,
          (S1 = {},
-          sat_step(R1,R2,_,F) 
+          sat_step(R1,R2,_,F)
          ;
           S1 = _R with X,
           sat_step([X in I2,subset(S1,setlog_term(I2))|R1],R2,_,F)
-         ). 
-sat_sub([subset(S,I)|R1],R2,c,F):-                   % subset({A/X},setlog_term(int(L,H)))    
+         ).
+sat_sub([subset(S,I)|R1],R2,c,F):-                   % subset({A/X},setlog_term(int(L,H)))
          nonvar(I), I = setlog_term(I2),!,           % for internal use only
          S = S1 with Z,
          (S1 = {},
-          sat_step([Z in I2|R1],R2,_,F) 
+          sat_step([Z in I2|R1],R2,_,F)
          ;
           S1 = _R with X,
           sat_step([Z in I2,X in I2,X > Z,subset(S1,I)|R1],R2,_,F)
          ).
-sat_sub([subset(S1,S2)|R1],R2,c,F):-                 % subset(X,S2)                   
+sat_sub([subset(S1,S2)|R1],R2,c,F):-                 % subset(X,S2)
          var(S1),!,
-         sat_step([un(S1,S2,S2)|R1],R2,_,F). 
-sat_sub([subset({},_S2)|R1],R2,c,F):- !,             % subset({},S2)                  
-         sat_step(R1,R2,_,F). 
-sat_sub([subset(R with X,I2)|R1],R2,c,F):-           % subset({X|R},int(L,H))                 
+         sat_step([un(S1,S2,S2)|R1],R2,_,F).
+sat_sub([subset({},_S2)|R1],R2,c,F):- !,             % subset({},S2)
+         sat_step(R1,R2,_,F).
+sat_sub([subset(R with X,I2)|R1],R2,c,F):-           % subset({X|R},int(L,H))
          nonvar(I2), is_int(I2,_,_),!,
          sat_step([X in I2,subset(R,I2)|R1],R2,_,F).
-sat_sub([subset(R with X,S2)|R1],R2,c,F):- !,        % subset({X|R},S2)  
+sat_sub([subset(R with X,S2)|R1],R2,c,F):- !,        % subset({X|R},S2)
          sunify(S2,N with X,_),
          sat_step([set(N),subset(R,S2)|R1],R2,_,F).
 sat_sub([subset(I,_)|R1],R2,c,F):-                   % subset(int(L,H),S2), with L>H   %EInt
-         is_int(I,L,H),L>H,!,             
-         sat_step(R1,R2,_,F). 
+         is_int(I,L,H),L>H,!,
+         sat_step(R1,R2,_,F).
 sat_sub([subset(I,I2)|R1],R2,c,F):-                  % subset(int(L,H),int(L2,H2))
          is_int(I,L,H), nonvar(I2), is_int(I2,L2,H2),!,
          L2 =< L, H2 >= H,
-         sat_step(R1,R2,_,F). 
-sat_sub([subset(I,S2)|R1],R2,c,F):-                  % subset(int(L,L),S2), S2 not interval   
+         sat_step(R1,R2,_,F).
+sat_sub([subset(I,S2)|R1],R2,c,F):-                  % subset(int(L,L),S2), S2 not interval
          is_int(I,L,H), L==H, !,
          sat_step([L in S2|R1],R2,_,F).
 sat_sub([subset(I,S2)|R1],R2,c,F):-                  % subset(int(L,H),S2), S2 not interval
@@ -2421,50 +2421,50 @@ sat_sub([subset(I,S2)|R1],R2,c,F):-                  % subset(int(L,H),S2), S2 n
          sat_step([L in S2,subset(int(L1,H),S2)|R1],R2,_,F).
 
 
-%%%%%%%%%%%%%%%%%%%%%% strict subset (ssubset/2)  
+%%%%%%%%%%%%%%%%%%%%%% strict subset (ssubset/2)
 
-sat_ssub([ssubset(S1,S2)|R1],R2,c,F):-                           
+sat_ssub([ssubset(S1,S2)|R1],R2,c,F):-
           sat_step([subset(S1,S2),S1 neq S2|R1],R2,_,F).
 
 
-%%%%%%%%%%%%%%%%%%%%%% intersection (inters/3)          
+%%%%%%%%%%%%%%%%%%%%%% intersection (inters/3)
 
 
-sat_inters([inters(S1,S2,S3)|R1],R2,c,F):-              % inters(S,S,S)      
+sat_inters([inters(S1,S2,S3)|R1],R2,c,F):-              % inters(S,S,S)
          S1 == S2,!,
          sunify(S1,S3,C),
-         append(C,R1,R3), 
+         append(C,R1,R3),
          sat_step(R3,R2,_,F).
 
-sat_inters([inters(S1,S2,S3)|R1],R2,c,F):-              % ground set: inters({...},{...},t)          
-         ground(S1), ground(S2), 
+sat_inters([inters(S1,S2,S3)|R1],R2,c,F):-              % ground set: inters({...},{...},t)
+         ground(S1), ground(S2),
          set_term(S1), set_term(S2),!,
          g_inters(S1,S2,S1_2),
          sunify(S1_2,S3,C),
-         append(C,R1,R3), 
+         append(C,R1,R3),
          sat_step(R3,R2,_,F).
 
-sat_inters([inters(I1,I2,S3)|R1],R2,c,F):-              % ground interval: inters(int(a,b),int(c,d),t),  
+sat_inters([inters(I1,I2,S3)|R1],R2,c,F):-              % ground interval: inters(int(a,b),int(c,d),t),
          nonvar(I1), is_int(I1,L1,H1),                  % a,b,c,d constants
          nonvar(I2), is_int(I2,L2,H2),!,
          g_greater(L1,L2,L3), g_smaller(H1,H2,H3),
          (L3 > H3,!,
-          sunify({},S3,C), 
+          sunify({},S3,C),
           append(C,R1,R3)
-          ; 
+          ;
           sunify(int(L3,H3),S3,C),
           append(C,R1,R3)
-         ), 
+         ),
          sat_step(R3,R2,_,F).
 
 sat_inters([inters(I1,I2,S3)|R1],R2,c,F):-              % non-ground interval - empty-interval case:
          nonvar(I1), int_term(I1),                      % inters(int(L1,H1),int(L2,H2),t)
-         nonvar(I2), int_term(I2),                      % either L1 or H1 or L2 or H2 var 
-         (sunify({},I1,C1) 
+         nonvar(I2), int_term(I2),                      % either L1 or H1 or L2 or H2 var
+         (sunify({},I1,C1)
           ;
           sunify({},I2,C1)
          ),
-         sunify({},S3,C2), 
+         sunify({},S3,C2),
          append(C1,C2,C12), append(C12,R1,R3),
          sat_step(R3,R2,_,F).
 sat_inters([inters(I1,I2,S3)|R1],R2,c,F):-              % non-ground interval - not empty-interval case:
@@ -2473,13 +2473,13 @@ sat_inters([inters(I1,I2,S3)|R1],R2,c,F):-              % non-ground interval -
          I1=int(L1,H1), I2=int(L2,H2),
          fd_max(L1,L2,L3), fd_min(H1,H2,H3),
          (solve_FD(L3 > H3),
-          sunify({},S3,C), 
+          sunify({},S3,C),
           append(C,R1,R3)
-          ; 
+          ;
           solve_FD(L3 =< H3),
           sunify(int(L3,H3),S3,C),
           append(C,R1,R3)
-         ), 
+         ),
          sat_step([I1 neq {},I2 neq {}|R3],R2,_,F).
 
 sat_inters([inters(_S1,S2,S3)|R1],R2,c,F):-             % ground empty-set/empty-interval:
@@ -2494,7 +2494,7 @@ sat_inters([inters(S1,_S2,S3)|R1],R2,c,F):-             % (case ii) inters(empty
          sat_step(R3,R2,_,F).
 
 sat_inters([inters(S1,S2,S3)|R1],R2,c,F):-              % set/interval - set - variable (A,B either constants or vars)
-         nonvar(S1),                                    % inters({...},{...},S3) or inters(int(A,B),{...},S3), S3 var                   
+         nonvar(S1),                                    % inters({...},{...},S3) or inters(int(A,B),{...},S3), S3 var
          nonvar(S2), S2 = RS2 with X,
          var(S3),!,
          (S3 = RS3 with X,
@@ -2503,89 +2503,89 @@ sat_inters([inters(S1,S2,S3)|R1],R2,c,F):-              % set/interval - set - v
           sat_step([set(RS2),X nin S1,inters(S1,RS2,S3)|R1],R2,_,F)
          ).
 sat_inters([inters(S1,S2,S3)|R1],R2,c,F):-              % set/interval - set - set/interval (A,B,C,D either constants or vars)
-         nonvar(S1),                                    % inters({...},{...},{...}) or inters({...},{...},int(A,B)) or                            
+         nonvar(S1),                                    % inters({...},{...},{...}) or inters({...},{...},int(A,B)) or
          nonvar(S2), S2 = _RS2 with _X,                 % inters(int(A,B),{...},{...}) or inters(int(A,B),{...},int(C,D))
-         nonvar(S3),!,      
+         nonvar(S3),!,
          sat_step([inters(S1,S2,SRes),SRes=S3|R1],R2,_,F).
 
 sat_inters([inters(S1,S2,S3)|R1],R2,c,F):-              % set - set/interval - set/interval (A,B,C,D either constants or vars)
-         nonvar(S2),                                    % inters({...},int(A,B)),{...}) or inters({...},int(A,B)),int(C,D))                           
-         nonvar(S1), S1 = _RS1 with _X,!,               % inters({...},int(A,B),S3) 
+         nonvar(S2),                                    % inters({...},int(A,B)),{...}) or inters({...},int(A,B)),int(C,D))
+         nonvar(S1), S1 = _RS1 with _X,!,               % inters({...},int(A,B),S3)
          sat_step([inters(S2,S1,S3)|R1],R2,_,F).
 
-sat_inters([inters(S1,S2,S3)|R1],[inters(S1,S2,S3)|R2],Stop,nf):-  % general cases: inters(S1,.,.) or inters(.,S2,.), S1,S2 vars   
-         var(S1),!,                                     % delayed until final_sat is called 
-         sat_step(R1,R2,Stop,nf).                   
-sat_inters([inters(S1,S2,S3)|R1],[inters(S1,S2,S3)|R2],Stop,nf):-               
-         var(S2),!,                                     % delayed until final_sat is called 
-         sat_step(R1,R2,Stop,nf).                   
+sat_inters([inters(S1,S2,S3)|R1],[inters(S1,S2,S3)|R2],Stop,nf):-  % general cases: inters(S1,.,.) or inters(.,S2,.), S1,S2 vars
+         var(S1),!,                                     % delayed until final_sat is called
+         sat_step(R1,R2,Stop,nf).
+sat_inters([inters(S1,S2,S3)|R1],[inters(S1,S2,S3)|R2],Stop,nf):-
+         var(S2),!,                                     % delayed until final_sat is called
+         sat_step(R1,R2,Stop,nf).
 sat_inters([inters(S1,S2,S3)|R1],R2,c,f):-              % LEVEL 3: inters(t1,t2,t3)
          (var(S1),! ; var(S2)),
-         sat_step([un(D,S3,S1),un(E,S3,S2),disj(D,E)|R1],R2,_,f). 
+         sat_step([un(D,S3,S1),un(E,S3,S2),disj(D,E)|R1],R2,_,f).
 
 
 %%%%%%%%%%%%%%%%%%%%%% union (un/3)
 
-sat_un([un(S1,S2,T)|R1],R2,c,F):-                    % un(s,s,t) 
+sat_un([un(S1,S2,T)|R1],R2,c,F):-                    % un(s,s,t)
          S1==S2,!,                                   % includes un({},{},t)
-         sunify(S1,T,C), 
-         append(C,R1,R3), 
-         sat_step(R3,R2,_,F). 
+         sunify(S1,T,C),
+         append(C,R1,R3),
+         sat_step(R3,R2,_,F).
 sat_un([un(X,Y,Z)|R1],R2,c,F):-                      % un(Y,X,Z) --> un(X,Y,Z)
          var(X),var(Y),var(Z),
          X @> Y,!,
-         sat_step([un(Y,X,Z)|R1],R2,_,F).                         
+         sat_step([un(Y,X,Z)|R1],R2,_,F).
 sat_un([un(X,Y,Z)|R1],[un(X,Y,Z)|R2],Stop,F):-       % un(X,Y,Z) (irreducible form)
-         var(X),var(Y),var(Z),!,                     
+         var(X),var(Y),var(Z),!,
          sat_step(R1,R2,Stop,F).
-sat_un([un(T1,T2,S)|R1],R2,c,F):-                    % un({},s,t) 
-         nonvar(T1), is_empty(T1),!, 
-         sunify(S,T2,C), 
-         append(C,R1,R3), 
-         sat_step(R3,R2,_,F).         
-sat_un([un(T1,T2,S)|R1],R2,c,F):-                    % un(t,{},s) 
+sat_un([un(T1,T2,S)|R1],R2,c,F):-                    % un({},s,t)
+         nonvar(T1), is_empty(T1),!,
+         sunify(S,T2,C),
+         append(C,R1,R3),
+         sat_step(R3,R2,_,F).
+sat_un([un(T1,T2,S)|R1],R2,c,F):-                    % un(t,{},s)
          nonvar(T2), is_empty(T2),!,
-         sunify(S,T1,C), 
-         append(C,R1,R3),  
-         sat_step(R3,R2,_,F).         
-sat_un([un(T1,T2,T3)|R1],R2,c,F):-                   % un(s,t,{}) 
-         nonvar(T3), is_empty(T3),!, 
-         unify_empty(T1), unify_empty(T2), 
+         sunify(S,T1,C),
+         append(C,R1,R3),
+         sat_step(R3,R2,_,F).
+sat_un([un(T1,T2,T3)|R1],R2,c,F):-                   % un(s,t,{})
+         nonvar(T3), is_empty(T3),!,
+         unify_empty(T1), unify_empty(T2),
          sat_step(R1,R2,_,F).
 
-sat_un([un(I1,I2,S)|R1], R2, c, F) :-                % un(int(...),int(...),s) 
+sat_un([un(I1,I2,S)|R1], R2, c, F) :-                % un(int(...),int(...),s)
          nonvar(I1), nonvar(I2),
-         is_int(I1,A1,B1), is_int(I2,A2,B2), 
+         is_int(I1,A1,B1), is_int(I2,A2,B2),
          B1 >= A2,!,
          A3 is min(A1,A2),
          B3 is max(B1,B2),
          sunify(int(A3,B3),S,C),
-         append(C,R1,R3),  
-         sat_step(R3,R2,_,F).  
-sat_un([un(I1,I2,S)|R1], R2, c, F) :-                % un(int(...),int(...),s) 
+         append(C,R1,R3),
+         sat_step(R3,R2,_,F).
+sat_un([un(I1,I2,S)|R1], R2, c, F) :-                % un(int(...),int(...),s)
          nonvar(I1), nonvar(I2),
-         is_int(I1,_A1,B1), is_int(I2,A2,_B2), 
+         is_int(I1,_A1,B1), is_int(I2,A2,_B2),
          B1 < A2,!,
          int_to_set(I2,S2),
          int_to_set(I1,S1,S2),
          sunify(S1,S,C),
-         append(C,R1,R3),  
-         sat_step(R3,R2,_,F).  
+         append(C,R1,R3),
+         sat_step(R3,R2,_,F).
 
-sat_un([un(S1,S2,I)|R1], R2, c, F) :-                % un(s1,s2,int(L,L)) 
+sat_un([un(S1,S2,I)|R1], R2, c, F) :-                % un(s1,s2,int(L,L))
          nonvar(I), is_int(I,T1,T2), T1==T2, !,
-         sat_step([un(S1,S2,{} with T1)|R1],R2,_,F).               
-sat_un([un(S1,S2,I)|R1], R2, c, F) :-                % un(s1,s2,int(...)) 
-         nonvar(I), is_int(I,T1,T2), 
+         sat_step([un(S1,S2,{} with T1)|R1],R2,_,F).
+sat_un([un(S1,S2,I)|R1], R2, c, F) :-                % un(s1,s2,int(...))
+         nonvar(I), is_int(I,T1,T2),
          sunify(N1 with T1,S1,C1), append(C1,R1,C2),
          T3 is T1 + 1,
-         sat_step([T1 nin N1,set(N1),un(N1,S2,int(T3,T2)) | C2],R2,_,F).               
-sat_un([un(S1,S2,I)|R1], R2, c, F) :-                % un(s1,s2,int(...)) 
-         nonvar(I), is_int(I,T1,T2), 
+         sat_step([T1 nin N1,set(N1),un(N1,S2,int(T3,T2)) | C2],R2,_,F).
+sat_un([un(S1,S2,I)|R1], R2, c, F) :-                % un(s1,s2,int(...))
+         nonvar(I), is_int(I,T1,T2),
          sunify(N1 with T1,S2,C1), append(C1,R1,C2),
          T3 is T1 + 1,
          sat_step([T1 nin N1,set(N1),un(S1,N1,int(T3,T2)) | C2],R2,_,F).
-sat_un([un(S1,S2,I)|R1], R2, c, F) :-                % un(s1,s2,int(...)) 
+sat_un([un(S1,S2,I)|R1], R2, c, F) :-                % un(s1,s2,int(...))
          nonvar(I), is_int(I,T1,T2), !,
          sunify(N1 with T1,S1,C1),
          sunify(N2 with T1,S2,C2),
@@ -2593,28 +2593,28 @@ sat_un([un(S1,S2,I)|R1], R2, c, F) :-                % un(s1,s2,int(...))
          T3 is T1 + 1,
          sat_step([T1 nin N1,T1 nin N2,set(N1),set(N2),un(N1,N2,int(T3,T2)) | C4],R2,_,F).
 
-sat_un([un(S1,S2,S3)|R1],R2,c,F):-                   % un({.../R},s2,{.../R}) or un(s1,{.../R},{.../R}) (special cases) 
+sat_un([un(S1,S2,S3)|R1],R2,c,F):-                   % un({.../R},s2,{.../R}) or un(s1,{.../R},{.../R}) (special cases)
          nonvar(S3), S3=_ with T1,
          tail(S1,TS1), tail(S2,TS2), tail(S3,TS3),
-         samevar(TS3,TS1,TS2),!, 
+         samevar(TS3,TS1,TS2),!,
          sunify(N with T1,S3,C1),
          ( sunify(N1 with T1,S1,C2),                               % (i)
-           append(C1,C2,C3), 
+           append(C1,C2,C3),
            R = [T1 nin N,T1 nin N1,T1 nin S2,set(N1),set(N),un(N1,S2,N)|C3]
          ;
            sunify(N1 with T1,S2,C2),                               % (ii)
-           append(C1,C2,C3), 
+           append(C1,C2,C3),
            R = [T1 nin N,T1 nin N1,T1 nin S1,set(N1),set(N),un(S1,N1,N)|C3]
          ;
            sunify(N1 with T1,S1,C21), sunify(N2 with T1,S2,C22),   % (iii)
-           append(C21,C22,C2), append(C1,C2,C3), 
-           R = [T1 nin N,T1 nin N1,T1 nin N2,set(N1),set(N2),set(N),un(N1,N2,N)|C3] 
-         ),                
+           append(C21,C22,C2), append(C1,C2,C3),
+           R = [T1 nin N,T1 nin N1,T1 nin N2,set(N1),set(N2),set(N),un(N1,N2,N)|C3]
+         ),
          append(R,R1,R3),
          sat_step(R3,R2,_,F).
 
-sat_un([un(S1,S2,S3)|R1],R2,c,F):-                   % un(s1,s2,{...})  
-         nonvar(S3), S3=N with T1,!, 
+sat_un([un(S1,S2,S3)|R1],R2,c,F):-                   % un(s1,s2,{...})
+         nonvar(S3), S3=N with T1,!,
          ( sunify(N1 with T1,S1,C2),                               % (i)
            R = [T1 nin S2,set(N1),set(N),un(S2,N1,N)|C2]
          ;
@@ -2622,25 +2622,25 @@ sat_un([un(S1,S2,S3)|R1],R2,c,F):-                   % un(s1,s2,{...})
            R = [T1 nin S1,set(N1),set(N),un(S1,N1,N)|C2]
          ;
            sunify(N1 with T1,S1,C21), sunify(N2 with T1,S2,C22),   % (iii)
-           append(C21,C22,C2), 
-           R = [set(N1),set(N2),set(N),un(N1,N2,N)|C2] 
-         ),                
+           append(C21,C22,C2),
+           R = [set(N1),set(N2),set(N),un(N1,N2,N)|C2]
+         ),
          append(R,R1,R3),
          sat_step(R3,R2,_,F).
 
-sat_un([un(I,S,X)|R1], R2, c, F) :-                  % un(int(L,L),s,X) 
-         var(X), 
-         nonvar(I), is_int(I,T1,T2), T1==T2, !, 
-         sat_step([un({} with T1,S,X)|R1],R2,_,F).               
+sat_un([un(I,S,X)|R1], R2, c, F) :-                  % un(int(L,L),s,X)
+         var(X),
+         nonvar(I), is_int(I,T1,T2), T1==T2, !,
+         sat_step([un({} with T1,S,X)|R1],R2,_,F).
 sat_un([un(I,S,X)|R1], R2, c, F) :-                  % un(int(...),s,X) (i)
-         var(X), 
-         nonvar(I), is_int(I, T1, T2),  
+         var(X),
+         nonvar(I), is_int(I, T1, T2),
          T3 is T1 + 1,
          sunify(N with T1, X, C1),
          append(C1, R1, C2),
          sat_step([T1 nin N,T1 nin S,set(N),un(int(T3,T2),S,N) | C2], R2, _, F).
 sat_un([un(I,S,X)|R1], R2, c, F) :-                  % un(int(...),s,X) (ii)
-         var(X), 
+         var(X),
          nonvar(I), is_int(I, T1, T2),!,
          T3 is T1 + 1,
          sunify(N with T1, X, C1),
@@ -2648,50 +2648,50 @@ sat_un([un(I,S,X)|R1], R2, c, F) :-                  % un(int(...),s,X) (ii)
          append(C1, R1, C3),
          append(C2, C3, C4),
          sat_step([T1 nin N,T1 nin N1,set(N),set(N1),un(int(T3,T2),N1,N) | C4], R2, _, F).
-sat_un([un(S,I,X)|R1],R2,c,F):-                      % un(s,int(...),X)           
+sat_un([un(S,I,X)|R1],R2,c,F):-                      % un(s,int(...),X)
          var(X),
          nonvar(I), is_int(I, _T1, _T2),!,
-         sat_step([un(I,S,X)|R1],R2,_,F).   
+         sat_step([un(I,S,X)|R1],R2,_,F).
 
-sat_un([un(S,T,X)|R1],R2,R,F):-                      % un({...},s2,X) (bounded sets) 
+sat_un([un(S,T,X)|R1],R2,R,F):-                      % un({...},s2,X) (bounded sets)
          var(X),
          occur_check(X,S), occur_check(X,T),
          bounded(S),!,
          sat_un_s([un(S,T,X)|R1],R2,R,F).
-sat_un([un(S,T,X)|R1],R2,R,F):-                      % un(s1,{...},X) (bounded sets) 
+sat_un([un(S,T,X)|R1],R2,R,F):-                      % un(s1,{...},X) (bounded sets)
          var(X),
          occur_check(X,S), occur_check(X,T),
          bounded(T),!,
          sat_un_t([un(S,T,X)|R1],R2,R,F).
 
-sat_un([un(S,T,X)|R1],R2,c,F):-                      % un({...|X},t,X)    
+sat_un([un(S,T,X)|R1],R2,c,F):-                      % un({...|X},t,X)
          nonvar(S), var(X),
          tail(S,TS),samevar(TS,X),!,
          replace_tail(S,N,NewS),
         (samevar(TS,T),!,sat_step([X=NewS,set(N)|R1],R2,_,F)  % un({...|X},X,X)
          ;
-         sat_step([X=NewS,un(T,N,N),set(N)|R1],R2,_,F)).   
-sat_un([un(S,T,X)|R1],R2,c,F):-                      % un(s,{...|X},X)    
+         sat_step([X=NewS,un(T,N,N),set(N)|R1],R2,_,F)).
+sat_un([un(S,T,X)|R1],R2,c,F):-                      % un(s,{...|X},X)
          nonvar(T), var(X),
          tail(T,TT),samevar(TT,X),!,
          replace_tail(T,N,NewT),
-        (samevar(TT,S),!,sat_step([X=NewT,set(N)|R1],R2,_,F)  % un(X,{...|X},X) 
+        (samevar(TT,S),!,sat_step([X=NewT,set(N)|R1],R2,_,F)  % un(X,{...|X},X)
          ;
-         sat_step([X=NewT,un(S,N,N),set(N)|R1],R2,_,F)).   
+         sat_step([X=NewT,un(S,N,N),set(N)|R1],R2,_,F)).
 
-sat_un([un(S,T,X)|R1],[un(S,T,X)|R2],Stop,nf):-      %  
+sat_un([un(S,T,X)|R1],[un(S,T,X)|R2],Stop,nf):-      %
          var(X),!,                                   % delayed until final_sat is called
          sat_step(R1,R2,Stop,nf).                    % (--> Level 3)
-sat_un([un(S,T,X)|R1],R2,c,f):-                      % un({.../R},s,X) 
-         var(X), nonvar(S), 
+sat_un([un(S,T,X)|R1],R2,c,f):-                      % un({.../R},s,X)
+         var(X), nonvar(S),
          S = N1 with T1,
-         occur_check(X,S), novar_occur_check(X,T),!,     
+         occur_check(X,S), novar_occur_check(X,T),!,
          X = N with T1,
          sat_step([set(N),set(N1),un(N1,T,N)|R1],R2,_,f).
-sat_un([un(T,S,X)|R1],R2,c,f):-                      % un(t,{.../S},X)            
-         var(X), nonvar(S), 
+sat_un([un(T,S,X)|R1],R2,c,f):-                      % un(t,{.../S},X)
+         var(X), nonvar(S),
          S=_T2 with _T1, !,
-         sat_step([un(S,T,X)|R1],R2,_,f).  
+         sat_step([un(S,T,X)|R1],R2,_,f).
 
 sat_un_s([un(S,T,X)|R1],R2,c,F):-                    % un({...},s2,X) (bounded set case)
          g_union(S,T,X),
@@ -2703,7 +2703,7 @@ sat_un_t([un(S,T,X)|R1],R2,c,F):-                    % un(s1,{...},X) (bounded s
 unify_empty(S) :-
         var(S), !, S = {}.
 unify_empty({}) :- !.
-unify_empty(S) :- !,   
+unify_empty(S) :- !,
         is_int(S,L,H),
         L > H.
 
@@ -2722,35 +2722,35 @@ novar_occur_check(X,T) :-
 sat_disj([disj(X,Y)|R1],R2,c,F):-                            % disj(X,X)
         var(X), var(Y), samevar(X,Y),!,
         X = {},
-        sat_step(R1,R2,_,F).                                 
+        sat_step(R1,R2,_,F).
 sat_disj([disj(X,Y)|R1],R2,c,F):-                            % disj(Y,X) --> disj(X,Y)
         var(X),var(Y),
         X @> Y,!,
-        sat_step([disj(Y,X)|R1],R2,_,F).                         
+        sat_step([disj(Y,X)|R1],R2,_,F).
 sat_disj([disj(X,Y)|R1],[disj(X,Y)|R2],Stop,F):-             % disj(X,Y) (irreducible form)
         var(X), var(Y),!,
         sat_step(R1,R2,Stop,F).
-sat_disj([disj(Set1,Set2)|R1],R2,c,F):-                      % disj({...},{...}) 
+sat_disj([disj(Set1,Set2)|R1],R2,c,F):-                      % disj({...},{...})
         nonvar(Set1), Set1 = S1 with T1,
         nonvar(Set2), Set2 = S2 with T2,!,
         sat_step([T1 neq T2,T1 nin S2,T2 nin S1,set(S1),set(S2),disj(S1,S2)|R1],R2,_,F).
-sat_disj([disj(Set,X)|R1],R2,c,F):-                          % disj({...},X)   
+sat_disj([disj(Set,X)|R1],R2,c,F):-                          % disj({...},X)
         nonvar(Set), Set = T2 with T1,
         var(X),!,
         sat_step([T1 nin X,set(T2),disj(X,T2)|R1],R2,_,F).
-sat_disj([disj(X,Set)|R1],R2,c,F):-                          % disj(X,{...})   
+sat_disj([disj(X,Set)|R1],R2,c,F):-                          % disj(X,{...})
         nonvar(Set), Set = T2 with T1,
         var(X),!,
         sat_step([T1 nin X,set(T2),disj(X,T2)|R1],R2,_,F).
-sat_disj([disj(Set1,_)|R1],R2,c,F):-                         % disj({},t) or disj(int(a,b),t) with a > b 
+sat_disj([disj(Set1,_)|R1],R2,c,F):-                         % disj({},t) or disj(int(a,b),t) with a > b
         nonvar(Set1), is_empty(Set1),!,
         sat_step(R1,R2,_,F).
-sat_disj([disj(_,Set2)|R1],R2,c,F):-                         % disj(t,{}) or disj(t,int(a,b)) with a > b  
+sat_disj([disj(_,Set2)|R1],R2,c,F):-                         % disj(t,{}) or disj(t,int(a,b)) with a > b
         nonvar(Set2), is_empty(Set2),!,
         sat_step(R1,R2,_,F).
-sat_disj([disj(I1,I2)|R1],R2,c,F):-                          % disj(int(a,b),int(c,d)) 
-        nonvar(I1), is_int(I1,S1,S2),        
-        nonvar(I2), is_int(I2,T1,T2),!,        
+sat_disj([disj(I1,I2)|R1],R2,c,F):-                          % disj(int(a,b),int(c,d))
+        nonvar(I1), is_int(I1,S1,S2),
+        nonvar(I2), is_int(I2,T1,T2),!,
         (solve_FD(S2 + 1 =< T1)
          ;
          solve_FD(T2 + 1 =< S1)
@@ -2758,31 +2758,31 @@ sat_disj([disj(I1,I2)|R1],R2,c,F):-                          % disj(int(a,b),int
          solve_FD(S2 + 1 =< T1), solve_FD(T2 + 1 =< S1)
         ),
         sat_step(R1,R2,_,F).
-sat_disj([disj(I1,Set)|R1],R2,c,F):-                         % disj(int(A,A),t)  
+sat_disj([disj(I1,Set)|R1],R2,c,F):-                         % disj(int(A,A),t)
         nonvar(I1), is_int(I1,S1,S2), S1==S2, !,
         sat_step([S1 nin Set|R1],R2,_,F).
-sat_disj([disj(I1,Set)|R1],R2,c,F):-                         % disj(int(a,b),t)  
+sat_disj([disj(I1,Set)|R1],R2,c,F):-                         % disj(int(a,b),t)
         nonvar(I1), is_int(I1,S1,S2),!,
         S3 is S1 + 1,
         sat_step([S1 nin Set, disj(int(S3,S2),Set)|R1],R2,_,F).
-sat_disj([disj(Set,I1)|R1],R2,c,F):-                         % disj(t,int(a,b))  
+sat_disj([disj(Set,I1)|R1],R2,c,F):-                         % disj(t,int(a,b))
         nonvar(I1), is_int(I1,_S1,_S2),
         sat_step([disj(I1,Set)|R1],R2,_,F).
-       
+
 %%%%%%%%%%%%%%%%%%%%%% not union (nun/3)
 
-sat_nun([nun(S1,S2,S3)|R1],R2,c,F):-               % nun(s1,s2,s3) 
+sat_nun([nun(S1,S2,S3)|R1],R2,c,F):-               % nun(s1,s2,s3)
         sat_step([N in S3,N nin S1,N nin S2|R1],R2,_,F).
-sat_nun([nun(S1,_S2,S3)|R1],R2,c,F):-              % 
+sat_nun([nun(S1,_S2,S3)|R1],R2,c,F):-              %
         sat_step([N in S1,N nin S3|R1],R2,_,F).
-sat_nun([nun(_S1,S2,S3)|R1],R2,c,F):-              % 
+sat_nun([nun(_S1,S2,S3)|R1],R2,c,F):-              %
         sat_step([N in S2,N nin S3|R1],R2,_,F).
 
 %%%%%%%%%%%%%%%%%%%%%% not disjointness (ndisj/2)
 
-sat_ndisj([ndisj(I1,I2)|R1],R2,c,F):-              % ndisj(int(...),int(...)) 
-        nonvar(I1), is_int(I1,S1,S2),        
-        nonvar(I2), is_int(I2,T1,T2),!,        
+sat_ndisj([ndisj(I1,I2)|R1],R2,c,F):-              % ndisj(int(...),int(...))
+        nonvar(I1), is_int(I1,S1,S2),
+        nonvar(I2), is_int(I2,T1,T2),!,
         (solve_FD(S1 =< T1), solve_FD(T1 =< S2)
          ;
          solve_FD(T1 =< S1), solve_FD(S1 =< T2)
@@ -2790,7 +2790,7 @@ sat_ndisj([ndisj(I1,I2)|R1],R2,c,F):-              % ndisj(int(...),int(...))
         sat_step(R1,R2,_,F).
 sat_ndisj([ndisj(X,Y)|R1],R2,c,F):-                % ndisj(X,X)
         var(X), var(Y), samevar(X,Y),!,
-        sat_step(R1,R2,_,F).                                 
+        sat_step(R1,R2,_,F).
 sat_ndisj([ndisj(S,T)|R1],R2,c,F):-                % ndisj({...},{...})
         sat_step([N in S, N in T|R1],R2,_,F).
 
@@ -2798,59 +2798,59 @@ sat_ndisj([ndisj(S,T)|R1],R2,c,F):-                % ndisj({...},{...})
 %%%%%%%%%%%% Rewriting rules for aggregate constraints %%%%%%%%%%%%
 %%%%%%%%%%%%
 
-%%%%%%%%%%%%%%%%%%%%%% set cardinality (size/2)              
+%%%%%%%%%%%%%%%%%%%%%% set cardinality (size/2)
 
 sat_size([size(S,N)|R1],
-        [solved(size(S,N),(var(S),var(N)),1,f)|R2],c,F):-   %   
+        [solved(size(S,N),(var(S),var(N)),1,f)|R2],c,F):-   %
         var(S),var(N),!,                           % size(S,N) (irreducible form)
         solve_FD(N >= 0),
         sat_step(R1,R2,_,F).
-sat_size([size(S,0)|R1],R2,c,F):-                  % size({},t) or size(int(a,b),t), 
-        is_empty(S),!,                             % with a>b (S either var or nonvar)           
-        sat_step(R1,R2,_,F).                       
+sat_size([size(S,0)|R1],R2,c,F):-                  % size({},t) or size(int(a,b),t),
+        is_empty(S),!,                             % with a>b (S either var or nonvar)
+        sat_step(R1,R2,_,F).
 sat_size([size(I,T)|R1],R2,c,F):-                  % size(int(a,b),t)
-        nonvar(I), is_int(I,A,B),!,   
-        simple_integer_expr(T),     
+        nonvar(I), is_int(I,A,B),!,
+        simple_integer_expr(T),
         solve_FD(T is B-A+1),
         sat_step(R1,R2,_,F).
 sat_size([size(S,T)|R1],R2,c,F):-                  % ground case
-        ground(S),!,                
-        simple_integer_expr(T),     
+        ground(S),!,
+        simple_integer_expr(T),
         g_size(S,T),
         sat_step(R1,R2,_,F).
 sat_size([size(S,T)|R1],[size(S,T)|R2],Stop,nf):-  % size(S,k), S var., k nonvar
-        var(S),!,                                  % delayed until final_sat is called 
-        sat_step(R1,R2,Stop,nf).                   
+        var(S),!,                                  % delayed until final_sat is called
+        sat_step(R1,R2,Stop,nf).
 sat_size([size(S,T)|R1],R2,c,f):-                  % LEVEL 3: size(S,k), S var., k int. const.
-        var(S),!,                                  
-        integer(T),         
+        var(S),!,
+        integer(T),
         solve_FD(T >= 1),
         S = R with X,
         solve_FD(M is T-1),
-        sat_step([X nin R,set(R),integer(M),size(R,M)|R1],R2,_,f). 
-%sat_size([size(S,T)|R1],[solved(size(S,T),true,1,nf)|R2],c,nf):-   %   
-%        bounded(S),!,                       % size(S,t), S bounded set {t1,...,tn}          
-%        simple_integer_expr(T),             % delayed until final_sat is called 
-%        solve_FD(T >= 1),            
-%        count_var(S,NVar,Var),   % FOR SET OF VARs ONLY: TO BE EXTENDED TO GENERAL TERMS!              
+        sat_step([X nin R,set(R),integer(M),size(R,M)|R1],R2,_,f).
+%sat_size([size(S,T)|R1],[solved(size(S,T),true,1,nf)|R2],c,nf):-   %
+%        bounded(S),!,                       % size(S,t), S bounded set {t1,...,tn}
+%        simple_integer_expr(T),             % delayed until final_sat is called
+%        solve_FD(T >= 1),
+%        count_var(S,NVar,Var),   % FOR SET OF VARs ONLY: TO BE EXTENDED TO GENERAL TERMS!
 %        MaxNoTerm is NVar + Var,
 %        (NVar==0, MinNoTerm=1 ; NVar>0, MinNoTerm=NVar),
 %        solve_FD(T in int(MinNoTerm,MaxNoTerm)),
-%        sat_step(R1,R2,_,nf). 
+%        sat_step(R1,R2,_,nf).
 sat_size([size(R with X,T)|R1],[size(R with X,T)|R2],Stop,nf) :- !,   %size({...|R},t)
-        sat_step(R1,R2,Stop,nf).                   % delayed until final_sat is called  
-sat_size([size(R with X,T)|R1],R2,c,f):-           
+        sat_step(R1,R2,Stop,nf).                   % delayed until final_sat is called
+sat_size([size(R with X,T)|R1],R2,c,f):-
         simple_integer_expr(T),                    % LEVEL 3: size({...},t)
         solve_FD(T >= 1),
         solve_FD(M is T-1),
-        (sat_step([X nin R,set(R),integer(M),size(R,M)|R1],R2,_,f)     
+        (sat_step([X nin R,set(R),integer(M),size(R,M)|R1],R2,_,f)
          ;
          sat_step([R=N with X,set(N),X nin N,integer(M),size(N,M)|R1],R2,_,f)).
 
 count_var(T,0,0) :-      % count_var/3 not used at present
-        is_empty(T),!.                
+        is_empty(T),!.
 count_var(R with A,NonVar,Var):-           % var(A)
-        var(A),!,     
+        var(A),!,
         count_var(R,NonVar,Var1),
         Var is Var1 + 1.
 count_var(R with A,NonVar,Var):-           % nonvar(A), duplicate A
@@ -2868,153 +2868,153 @@ find_gdup(X,_R with Y) :-
 find_gdup(X,R with _Y) :-
         find_gdup(X,R).
 
-%%%%%%%%%%%%%%%%%%%%% set sum (sum/2)              
+%%%%%%%%%%%%%%%%%%%%% set sum (sum/2)
 
 sat_sum([sum(S,N)|R1],
-        [solved(sum(S,N),(var(S),var(N)),1,f)|R2],c,F):-   %  
+        [solved(sum(S,N),(var(S),var(N)),1,f)|R2],c,F):-   %
         var(S),var(N),!,                           % sum(S,N) (irreducible form)
         solve_FD(N >= 0),
         sat_step(R1,R2,_,F).
-sat_sum([sum(S,0)|R1],R2,c,F):-                    % sum({},t) or sum(int(a,b),t), 
+sat_sum([sum(S,0)|R1],R2,c,F):-                    % sum({},t) or sum(int(a,b),t),
         is_empty(S),!,                             % with a>b (S either var or nonvar)
-        sat_step(R1,R2,_,F).                       
+        sat_step(R1,R2,_,F).
 sat_sum([sum(I,T)|R1],R2,c,F):-                    % sum(int(a,b),t)
         nonvar(I),is_int(I,A,B),
-        A =< B,!,  
-        simple_integer_expr(T),     
+        A =< B,!,
+        simple_integer_expr(T),
         solve_FD(T is ((B*(B+1))-(A*(A-1)))/2),
         sat_step(R1,R2,_,F).
 sat_sum([sum(S,T)|R1],R2,c,F):-                    % ground case
-        ground(S),!,                
-        simple_integer_expr(T),     
-        g_sum(S,T),                 
+        ground(S),!,
+        simple_integer_expr(T),
+        g_sum(S,T),
         sat_step(R1,R2,_,F).
 sat_sum([sum(S,T)|R1],[sum(S,T)|R2],Stop,nf):-     % sum(S,k), k int. const, S var.
         var(S), integer(T),!,                      % delayed until final_sat is called
         sat_step(R1,R2,Stop,nf).                   % (--> Level 3)
-sat_sum([sum(S,T)|R1],[solved(sum(S,T),var(S),1,f)|R2],Stop,f):-        
+sat_sum([sum(S,T)|R1],[solved(sum(S,T),var(S),1,f)|R2],Stop,f):-
         var(S), integer(T),                        % LEVEL 3: sum(S,k), k int. const, S var.
         nolabel,!,                                 % if nolabel --> irreducible form
         sat_step(R1,R2,Stop,f).
 sat_sum([sum(S,T)|R1],R2,c,f):-                    % LEVEL 3: sum(S,k), k int. const, S var.
-        var(S), integer(T),!, 
-        solve_FD(T >= 0),            
+        var(S), integer(T),!,
+        solve_FD(T >= 0),
         sum_all(S,T,int(0,T),[]),
-        sat_step(R1,R2,_,f). 
+        sat_step(R1,R2,_,f).
 sat_sum([sum(R with X,T)|R1],
-        [solved(sum(R with X,T),true,1,nf)|R2],c,nf):-   %  
+        [solved(sum(R with X,T),true,1,nf)|R2],c,nf):-   %
         integer(T),!,                              % sum({...},k)
         solve_FD(T >= 0),                          % delayed until final_sat is called
-        add_elem_domain(R with X,T),        
-        sat_step(R1,R2,_,nf). 
-sat_sum([sum(R with X,T)|R1],[sum(R with X,T)|R2],Stop,nf):- !,  
+        add_elem_domain(R with X,T),
+        sat_step(R1,R2,_,nf).
+sat_sum([sum(R with X,T)|R1],[sum(R with X,T)|R2],Stop,nf):- !,
 %        var(T),!,                                 % sum({...},N)
-        sat_step(R1,R2,Stop,nf).                   % delayed until final_sat is called 
-sat_sum([sum(R with X,T)|R1],R2,c,f):-              
-        simple_integer_expr(T),                    % LEVEL 3: sum({...},t)  
-        simple_integer_expr(X),     
-        solve_FD(T >= 0),            
-        solve_FD(X >= 0),            
+        sat_step(R1,R2,Stop,nf).                   % delayed until final_sat is called
+sat_sum([sum(R with X,T)|R1],R2,c,f):-
+        simple_integer_expr(T),                    % LEVEL 3: sum({...},t)
+        simple_integer_expr(X),
+        solve_FD(T >= 0),
+        solve_FD(X >= 0),
         solve_FD(T is M+X),
-        (sat_step([integer(X),X nin R,set(R),sum(R,M)|R1],R2,_,f) 
-        ; 
-        sat_step([integer(X),R=N with X,X nin N,set(N),sum(N,M)|R1],R2,_,f) ). 
+        (sat_step([integer(X),X nin R,set(R),sum(R,M)|R1],R2,_,f)
+        ;
+        sat_step([integer(X),R=N with X,X nin N,set(N),sum(N,M)|R1],R2,_,f) ).
 
 sum_all({},0,_,_).
 sum_all(R with X,N,L,G) :-
-        solve_FD(X in L), 
+        solve_FD(X in L),
         in_order_list(X,G),
         solve_FD(N is X + M),
         sum_all(R,M,L,[X|G]),
         clpfd:indomain(X).
 
 in_order_list(_A,[]) :- !.
-in_order_list(A,[B|_R]) :-  
+in_order_list(A,[B|_R]) :-
         solve_FD(A > B).
 
-add_elem_domain(R,_):-     
+add_elem_domain(R,_):-
        var(R),!.
 add_elem_domain(T,_) :-
        is_empty(T),!.
-add_elem_domain(R with A,N):-                
-       solve_FD(A in int(0,N)),   
+add_elem_domain(R with A,N):-
+       solve_FD(A in int(0,N)),
        add_elem_domain(R,N).
 
 
 %%%%%%%% Under development - to be completed and tested
 
-%%%%%%%%%%%%%%%%%%%%%%  min  (min/2)   %%%%%%%%%%%        
+%%%%%%%%%%%%%%%%%%%%%%  min  (min/2)   %%%%%%%%%%%
 % find the minimum of a set S of non-negative integers.
 
 sat_min([smin(S,N)|R1],
-        [solved(smin(S,N),(var(S),var(N)),1,f)|R2],c,F):-   %  
+        [solved(smin(S,N),(var(S),var(N)),1,f)|R2],c,F):-   %
         var(S),var(N),!,               % smin(S,N) (irreducible form)
-        solve_FD(N >= 0),                    
+        solve_FD(N >= 0),
         sat_step(R1,R2,_,F).
-sat_min([smin(S,_)|_],_,c,_):-         % smin({},t) or smin(int(a,b),t) with a>b 
+sat_min([smin(S,_)|_],_,c,_):-         % smin({},t) or smin(int(a,b),t) with a>b
         nonvar(S),is_empty(S),!,
-        fail.                       
-sat_min([smin(S,T)|R1],R2,c,F):-       % smin({X},T)                       
+        fail.
+sat_min([smin(S,T)|R1],R2,c,F):-       % smin({X},T)
         nonvar(S),S=R with X,
         nonvar(R),is_empty(R),!,
         T = X,
         simple_integer_expr(T),
         solve_FD(T >= 0),
-        sat_step(R1,R2,_,F).       
+        sat_step(R1,R2,_,F).
 sat_min([smin(I,T)|R1],R2,c,F):-       % smin(int(a,b),t) t=a
         nonvar(I),is_int(I,A,_B),!,
-%        solve_FD(A=<B),   
+%        solve_FD(A=<B),
         T = A,
         solve_FD(T >= 0),
         sat_step(R1,R2,_,F).
-sat_min([smin(S,T)|R1],R2,c,F):-       % ground case 
-        ground(S),!,                
-        simple_integer_expr(T),     
+sat_min([smin(S,T)|R1],R2,c,F):-       % ground case
+        ground(S),!,
+        simple_integer_expr(T),
         g_min(S,T),
         sat_step(R1,R2,_,F).
 sat_min([smin(S,T)|R1],[smin(S,T)|R2],Stop,nf):-  % smin(S,t), S var., t nonvar
         var(S),!,                     % delayed until final_sat is called
         sat_step(R1,R2,Stop,nf).      % (--> Level 3)
-sat_min([smin(S,T)|R1],R2,R,f):-      % LEVEL 3: smin(S,k) S var., k nonvar      
-        var(S),!,                     % (k integer constant)          
-        integer(T),        
+sat_min([smin(S,T)|R1],R2,R,f):-      % LEVEL 3: smin(S,k) S var., k nonvar
+        var(S),!,                     % (k integer constant)
+        integer(T),
         solve_FD(T >= 0),
         (sat_step([S=N with X,set(N),integer(X),X nin N,X = T,smin(N,M),M > T|R1],R2,R,f)
          ;
-         sat_step([S={} with X,integer(X),X = T|R1],R2,R,f)). 
-sat_min([smin(R with X,T)|R1],[smin(R with X,T)|R2],Stop,nf):- 
+         sat_step([S={} with X,integer(X),X = T|R1],R2,R,f)).
+sat_min([smin(R with X,T)|R1],[smin(R with X,T)|R2],Stop,nf):-
         bounded(R with X),!,          % smin(s,t), s bounded
         simple_integer_expr(X),
-        solve_FD(T >= 0),    
-        minim(R with X,T),       
-        sat_step(R1,R2,Stop,nf).  
+        solve_FD(T >= 0),
+        minim(R with X,T),
+        sat_step(R1,R2,Stop,nf).
 sat_min([smin(R with X,T)|R1],[smin(R with X,T)|R2],Stop,nf):-!,  % smin({...|R},t)
         sat_step(R1,R2,Stop,nf).                % delayed until final_sat is called
-sat_min([smin({} with X,T)|R1],R2,c,f):-        % LEVEL 3: smin({...},t)           
+sat_min([smin({} with X,T)|R1],R2,c,f):-        % LEVEL 3: smin({...},t)
         simple_integer_expr(X),
-        solve_FD(T >= 0), 
-        sat_step([integer(X),X = T|R1],R2,_,f). 
-sat_min([smin(R with X,T)|R1],R2,c,f):-         % LEVEL 3: smin({...},t)           
+        solve_FD(T >= 0),
+        sat_step([integer(X),X = T|R1],R2,_,f).
+sat_min([smin(R with X,T)|R1],R2,c,f):-         % LEVEL 3: smin({...},t)
         simple_integer_expr(T),
         simple_integer_expr(X),
-        solve_FD(T >= 0), 
+        solve_FD(T >= 0),
         (sat_step([integer(X),set(R),X = T,smin(R,M),M >= T|R1],R2,_,f)
-         ; 
+         ;
          sat_step([integer(X),set(R),X > T,smin(R,T)|R1],R2,_,f)
-        ). 
+        ).
 
-minim({},_). 
-minim(int(A,_),A).                 
-minim(R with A,N):- 
-        simple_integer_expr(A),               
-        solve_FD(A >= N),  
+minim({},_).
+minim(int(A,_),A).
+minim(R with A,N):-
+        simple_integer_expr(A),
+        solve_FD(A >= N),
         minim(R,N).
 
 g_min(L,X) :-
         L = _R with A,
         integer(A),A>=0,
         gg_min(L,A,X).
-  
+
 gg_min({},P,M):-
         solve_FD(M is P).
 gg_min(int(A,_),P,M) :-
@@ -3023,76 +3023,76 @@ gg_min(R with A,P,M) :-
         integer(A), A>=0,
         fd_min(A,P,G),
         gg_min(R,G,M).
-   
+
 fd_min(X,Y,J) :-
         solve_FD(X > Y),
-        solve_FD(J is Y). 
+        solve_FD(J is Y).
 fd_min(X,Y,J) :-
         solve_FD(X =< Y),
         solve_FD(J is X).
 
-%%%%%%%%%%%%%%%%%%%%%% max (max/2)  %%%%%%%%%          
+%%%%%%%%%%%%%%%%%%%%%% max (max/2)  %%%%%%%%%
 
 sat_max([smax(S,N)|R1],
-        [solved(smax(S,N),(var(S),var(N)),1,f)|R2],c,F):-   %   
+        [solved(smax(S,N),(var(S),var(N)),1,f)|R2],c,F):-   %
         var(S),var(N),!,                % smax(S,N) (irreducible form)
-        solve_FD(N >= 0),           
+        solve_FD(N >= 0),
         sat_step(R1,R2,_,F).
-sat_max([smax(S,_)|_],_,c,_) :-         % smax({},t) or smax(int(a,b),t) with a>b 
+sat_max([smax(S,_)|_],_,c,_) :-         % smax({},t) or smax(int(a,b),t) with a>b
         nonvar(S),is_empty(S),!,
-        fail.                       
-sat_max([smax(S,T)|R1],R2,c,F):-        % smax({X},t)                       
+        fail.
+sat_max([smax(S,T)|R1],R2,c,F):-        % smax({X},t)
         nonvar(S),S=R with X,
         nonvar(R),is_empty(R),!,
         T = X,
         simple_integer_expr(T),
         solve_FD(T >= 0),
-        sat_step(R1,R2,_,F).       
+        sat_step(R1,R2,_,F).
 sat_max([smax(I,T)|R1],R2,c,F):-        % smax(int(a,b),t) t=b
         nonvar(I), is_int(I,_A,B),!,
-%        solve_FD(A=<B),   
+%        solve_FD(A=<B),
         T = B,
         solve_FD(T >= 0),
         sat_step(R1,R2,_,F).
 sat_max([smax(S,T)|R1],R2,c,F):-        % ground case
-        ground(S),!,                
-        simple_integer_expr(T),     
+        ground(S),!,
+        simple_integer_expr(T),
         g_max(S,T),
         sat_step(R1,R2,_,F).
 sat_max([smax(S,T)|R1],[smax(S,T)|R2],Stop,nf) :-  % smax(S,t), S var., t nonvar
-        var(S),!,                       % delayed until final_sat is called 
-        sat_step(R1,R2,Stop,nf).        % (--> Level 3)    
-sat_max([smax(S,T)|R1],R2,R,f):-        % LEVEL 3: smax(S,k) S var., k nonvar      
-        var(S),!,                       % (k integer constant)          
-        integer(T),     
+        var(S),!,                       % delayed until final_sat is called
+        sat_step(R1,R2,Stop,nf).        % (--> Level 3)
+sat_max([smax(S,T)|R1],R2,R,f):-        % LEVEL 3: smax(S,k) S var., k nonvar
+        var(S),!,                       % (k integer constant)
+        integer(T),
         solve_FD(T >= 0),
         (sat_step([S=N with X,set(N),integer(X),X nin N,X = T,smax(N,M),M < T|R1],R2,R,f)
          ;
-         sat_step([S={} with X,integer(X),X = T|R1],R2,R,f)). 
-sat_max([smax(R with X,T)|R1],[smax(R with X,T)|R2],Stop,nf):- 
-        bounded(R with X),!, 
+         sat_step([S={} with X,integer(X),X = T|R1],R2,R,f)).
+sat_max([smax(R with X,T)|R1],[smax(R with X,T)|R2],Stop,nf):-
+        bounded(R with X),!,
         simple_integer_expr(X),         % smax(s,t), s bounded
-        solve_FD(T >= 0),  
-        mass(R with X,T),       
-        sat_step(R1,R2,Stop,nf).  
+        solve_FD(T >= 0),
+        mass(R with X,T),
+        sat_step(R1,R2,Stop,nf).
 sat_max([smax(R with X,T)|R1],[smax(R with X,T)|R2],Stop,nf):-!,  % smax({...|R},t)
         sat_step(R1,R2,Stop,nf).                % delayed until final_sat is called
-sat_max([smax({} with X,T)|R1],R2,_,f) :-       % LEVEL 3: smax({...},t)  
+sat_max([smax({} with X,T)|R1],R2,_,f) :-       % LEVEL 3: smax({...},t)
         simple_integer_expr(X),
-        solve_FD(T >= 0), 
-        sat_step([integer(X),X = T|R1],R2,_,f). 
-sat_max([smax(R with X,T)|R1],R2,_,f) :-        % LEVEL 3: smax({...},t)  
+        solve_FD(T >= 0),
+        sat_step([integer(X),X = T|R1],R2,_,f).
+sat_max([smax(R with X,T)|R1],R2,_,f) :-        % LEVEL 3: smax({...},t)
         simple_integer_expr(T),
         simple_integer_expr(X),
-        solve_FD(T >= 0), 
+        solve_FD(T >= 0),
         (sat_step([set(R),integer(X),X = T,smax(R,M),M =< T|R1],R2,_,f)
-        ; 
-         sat_step([set(R),integer(X),X < T,smax(R,T)|R1],R2,_,f)). 
+        ;
+         sat_step([set(R),integer(X),X < T,smax(R,T)|R1],R2,_,f)).
 
 mass({},_).
-mass(int(_,B),B).                 
+mass(int(_,B),B).
 mass(R with A,N):-
-        simple_integer_expr(A),   
+        simple_integer_expr(A),
         solve_FD(A >= 0),
         solve_FD(A =< N),
         mass(R,N).
@@ -3100,7 +3100,7 @@ mass(R with A,N):-
 g_max(L,X) :-
         gg_max(L,0,X).
 
-gg_max({},P,M):- 
+gg_max({},P,M):-
         solve_FD(M is P).
 gg_max(int(_,B),P,M) :-
         fd_max(B,P,M).
@@ -3108,24 +3108,24 @@ gg_max(R with A,P,M) :-
         integer(A), A>=0,
         fd_max(A,P,G),
         gg_max(R,G,M).
-   
+
 fd_max(X,Y,X) :-
-        solve_FD(X >= Y). 
+        solve_FD(X >= Y).
 fd_max(X,Y,Y) :-
         solve_FD(X < Y).
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-%%%%%%%%%%%%%%%%%%% implementation of ground cases %%%%%%%%%%%%%%%%%%%              
+%%%%%%%%%%%%%%%%%%% implementation of ground cases %%%%%%%%%%%%%%%%%%%
 
-g_neq(T1,T2) :- 
+g_neq(T1,T2) :-
          \+g_equal(T1,T2).
 
-% deterministic membership (for intervals/sets/multisets/lists): 
+% deterministic membership (for intervals/sets/multisets/lists):
 % g_member(T,A) is true if A contains T (T, A non-variable terms)
-g_member(X,I):-                
-        is_int(I,A,B),integer(X),!, 
+g_member(X,I):-
+        is_int(I,A,B),integer(X),!,
         X >= A, X =< B.
 g_member(X,S):-
         aggr_comps(S,Y,_R),
@@ -3148,7 +3148,7 @@ g_subset(R with X,S2) :-
         g_member(X,S2),
         g_subset(R,S2).
 
-g_equal(T1,T2) :- 
+g_equal(T1,T2) :-
         is_empty(T1), is_empty(T2),!.
 g_equal(T1,T2) :-
         T1 = T2,!.
@@ -3157,13 +3157,13 @@ g_equal(T1,T2) :-
         g_subset(T2,T1).
 
 g_union(T,S,S) :-
-        is_empty(T),!.              
+        is_empty(T),!.
 g_union(S1 with X,S2,S3 with X) :-
         g_union(S1,S2,S3).
 
-g_inters(T,_S,{}) :- 
+g_inters(T,_S,{}) :-
         is_empty(T),!.
-g_inters(_S,T,{}) :- 
+g_inters(_S,T,{}) :-
         is_empty(T),!.
 g_inters(S1 with X,S2,S3 with X) :-
         g_member(X,S2),!,
@@ -3172,25 +3172,25 @@ g_inters(S1 with _X,S2,S3) :-
         g_inters(S1,S2,S3).
 
 g_size(T,0) :-
-        is_empty(T),!.            
-g_size(int(A,B),N) :- !, 
-        N is B-A+1.            
+        is_empty(T),!.
+g_size(int(A,B),N) :- !,
+        N is B-A+1.
 g_size(R with A,N):-
         g_member(A,R),!,
         g_size(R,N).
 g_size(R with _A,N):-
         solve_FD(N is M+1),
         g_size(R,M).
- 
+
 g_sum(T,0) :-
-        is_empty(T),!. 
+        is_empty(T),!.
 g_sum(R with A,N):-
-        integer(A), A >= 0,         
+        integer(A), A >= 0,
         g_member(A,R),!,
         g_sum(R,N).
-g_sum(R with A,N):-          
-        integer(A), A >= 0,            
-        solve_FD(N is M+A),   
+g_sum(R with A,N):-
+        integer(A), A >= 0,
+        solve_FD(N is M+A),
         g_sum(R,M).
 
 g_greater(X,Y,X) :- X >= Y,!.
@@ -3209,56 +3209,56 @@ g_smaller(_X,Y,Y).
 sat_set([set(X)|R1],[set(X)|R2],Stop,F):-        % set(X) (irreducible form)
         var(X),!,
         sat_step(R1,R2,Stop,F).
-sat_set([set(X)|R1],R2,c,F):-                    % set({}) 
+sat_set([set(X)|R1],R2,c,F):-                    % set({})
         X == {}, !,
         sat_step(R1,R2,_,F).
-sat_set([set(X)|R1],R2,c,F):-                    % set({...}) 
+sat_set([set(X)|R1],R2,c,F):-                    % set({...})
         X = _S with _A, !,
         sat_step(R1,R2,_,F).
-sat_set([set(X)|R1],R2,c,F):-                    % set(int(...))    
-        X = int(A,B),!, 
-        sat_step([integer(A),integer(B)|R1],R2,_,F).    
-sat_set([set(X)|R1],R2,c,F) :- 
-        is_ris(X,ris(_,_,_,_,_)),!,                 
-        sat_step(R1,R2,_,F).    
+sat_set([set(X)|R1],R2,c,F):-                    % set(int(...))
+        X = int(A,B),!,
+        sat_step([integer(A),integer(B)|R1],R2,_,F).
+sat_set([set(X)|R1],R2,c,F) :-
+        is_ris(X,ris(_,_,_,_,_)),!,
+        sat_step(R1,R2,_,F).
 
 %%%%%%%%%%%%%%%%%%%%%% bag (bag/1)
 
 sat_bag([bag(X)|R1],[bag(X)|R2],Stop,F):-        % bag(X) (irreducible form)
-        var(X),!, 
+        var(X),!,
         sat_step(R1,R2,Stop,F).
-sat_bag([bag(X)|R1],R2,c,F):- 
+sat_bag([bag(X)|R1],R2,c,F):-
         X == {}, !,
         sat_step(R1,R2,_,F).
-sat_bag([bag(X)|R1],R2,c,F):-                    
+sat_bag([bag(X)|R1],R2,c,F):-
         X = _S mwith _A,
         sat_step(R1,R2,_,F).
 
 %%%%%%%%%%%%%%%%%%%%%% list (list/1)
 
 sat_list([list(X)|R1],[list(X)|R2],Stop,F):-     % list(X) (irreducible form)
-        var(X),!, 
+        var(X),!,
         sat_step(R1,R2,Stop,F).
-sat_list([list(X)|R1],R2,c,F):- 
+sat_list([list(X)|R1],R2,c,F):-
         X == [], !,
         sat_step(R1,R2,_,F).
-sat_list([list(X)|R1],R2,c,F):-                    
+sat_list([list(X)|R1],R2,c,F):-
         X = [_A|_S],
         sat_step(R1,R2,_,F).
 
 %%%%%%%%%%%%%%%%%%%%%% integer (integer/1)
 
 sat_integer([integer(X)|R1],[integer(X)|R2],Stop,F):-  % integer(X) (irreducible form)
-        var(X),!,    
+        var(X),!,
         sat_step(R1,R2,Stop,F).
-sat_integer([integer(T)|R1],R2,c,F):-                  % integer(t), t is an integer constant            
+sat_integer([integer(T)|R1],R2,c,F):-                  % integer(t), t is an integer constant
         integer(T),
         sat_step(R1,R2,_,F).
 
 %%%%%%%%%%%%%%%%%%%%%% not integer (ninteger/1)
 
 sat_ninteger([ninteger(X)|R1],[ninteger(X)|R2],Stop,F) :-  % ninteger(X) (irreducible form)
-       var(X), !,    
+       var(X), !,
        sat_step(R1,R2,Stop,F).
 sat_ninteger([ninteger(X)|R1],R2,c,F) :-
        \+integer(X),
@@ -3268,7 +3268,7 @@ sat_ninteger([ninteger(X)|R1],R2,c,F) :-
 %%%%%% Rewriting rules for constraints over binary relations and partial functions %%%%%%%%%%%%
 %%%%%%%%%%%%
 
-%%%%%%%%%%%%%%%%%%%%%% binary relation (rel/1)  
+%%%%%%%%%%%%%%%%%%%%%% binary relation (rel/1)
 
 sat_rel([rel(X)|R1],[rel(X)|R2],Stop,F):-          % rel(X) (irreducible form)
         var(X),!,
@@ -3276,9 +3276,9 @@ sat_rel([rel(X)|R1],[rel(X)|R2],Stop,F):-          % rel(X) (irreducible form)
 sat_rel([rel(X)|R1],R2,c,F):-                      % rel({}) or or rel(int(a,b)) with a>b
         nonvar(X),is_empty(X),!,
         sat_step(R1,R2,_,F).
-sat_rel([rel(X)|R1],R2,c,F):-                      % rel({[t1,t2],...,[t1,t2],...})   
-        X = S with [_A1,_A2],!, 
-        sat_step([rel(S)|R1],R2,_,F).  
+sat_rel([rel(X)|R1],R2,c,F):-                      % rel({[t1,t2],...,[t1,t2],...})
+        X = S with [_A1,_A2],!,
+        sat_step([rel(S)|R1],R2,_,F).
 
 
 %%%%%%%%%%%%%%%%%%%%%% partial function (pfun/1)
@@ -3297,193 +3297,193 @@ sat_pfun([pfun(X)|R1],R2,c,F):-                    % pfun({[...],[...],...})
         X = S with [A1,_A2],
         not_occur(A1,S,C),
         append(C,R1,R3),
-        sat_step([pfun(S)|R3],R2,_,F).   
-sat_pfun([pfun(X)|R1],R2,c,F):-                    % pfun({[t1,t2],...,[t1,t2],...})   
-        X = S with [A1,A2], 
-        sunify(S,R with [A1,A2],_),                
+        sat_step([pfun(S)|R3],R2,_,F).
+sat_pfun([pfun(X)|R1],R2,c,F):-                    % pfun({[t1,t2],...,[t1,t2],...})
+        X = S with [A1,A2],
+        sunify(S,R with [A1,A2],_),
         not_occur(A1,R,C),
         append(C,R1,R3),
-        sat_step([pfun(R)|R3],R2,_,F).  
-%       sat_step([[A1,A2] nin R,pfun(R)|R3],R2,_,F).  
+        sat_step([pfun(R)|R3],R2,_,F).
+%       sat_step([[A1,A2] nin R,pfun(R)|R3],R2,_,F).
 
-not_occur(A,S,[dompf(S,D),A nin D,set(D)]) :-       
+not_occur(A,S,[dompf(S,D),A nin D,set(D)]) :-
         var(S),!.
 not_occur(_A,{},[]) :- !.
 not_occur(A,R with [A1,_A2],[A neq A1|CR]) :-
         not_occur(A,R,CR).
 
 is_pfun({}) :- !.
-is_pfun(PFun with P) :- 
-    is_pfun_cont(PFun,P), 
+is_pfun(PFun with P) :-
+    is_pfun_cont(PFun,P),
     is_pfun(PFun).
 
 is_pfun_cont({},_P1) :- !.
-is_pfun_cont(F1 with P2,P1) :- 
-    nofork(P1,P2), 
+is_pfun_cont(F1 with P2,P1) :-
+    nofork(P1,P2),
     is_pfun_cont(F1,P1).
 
-nofork([X1,_Y1],[X2,_Y2]) :- 
+nofork([X1,_Y1],[X2,_Y2]) :-
     X1 \== X2,!.
-nofork([X1,Y1],[X2,Y2]) :- 
+nofork([X1,Y1],[X2,Y2]) :-
     X1 = X2, Y1 = Y2.
 
-dom_all_known(R) :-      
+dom_all_known(R) :-
     nonvar(R), R={}, !.
-dom_all_known(R with [X,_]) :- 
+dom_all_known(R with [X,_]) :-
     ground(X),
     dom_all_known(R).
 
 
-%%%%%%%%%%%%%%%%%%%%%% domain of a binary relation (dom/2)  
+%%%%%%%%%%%%%%%%%%%%%% domain of a binary relation (dom/2)
 
 sat_dom([dom(X,Y)|R1],R2,c,F):-                   % dom(X,X)
-        var(X),var(Y),X==Y,!, X = {},                          
+        var(X),var(Y),X==Y,!, X = {},
         sat_step(R1,R2,_,F).
-sat_dom([dom(S,D)|R1],[dom(S,D)|R2],Stop,F):-     % dom(S,D) (irreducible form) 
-        var(S),var(D),!,                           
+sat_dom([dom(S,D)|R1],[dom(S,D)|R2],Stop,F):-     % dom(S,D) (irreducible form)
+        var(S),var(D),!,
         sat_step(R1,R2,Stop,F).
 sat_dom([dom(S,D)|R1],R2,c,F):-                   % dom({},d) or dom(int(a,b),d) with a>b
-        nonvar(S),is_empty(S),!, 
+        nonvar(S),is_empty(S),!,
         sunify(D,{},C),
         append(C,R1,R3),
-        sat_step(R3,R2,_,F).                         
+        sat_step(R3,R2,_,F).
 sat_dom([dom(S,D)|R1],R2,c,F):-                   % dom(s,{}) or dom(s,int(a,b)) with a>b
-        nonvar(D),is_empty(D),!, 
+        nonvar(D),is_empty(D),!,
         sunify(S,{},C),
         append(C,R1,R3),
-        sat_step(R3,R2,_,F).                     
-sat_dom([dom(S,D)|R1],R2,c,F):-                   % dom({[...],...},D) or dom({[...],...},{...}) or dom({[...],...},int(t1,t2))      
+        sat_step(R3,R2,_,F).
+sat_dom([dom(S,D)|R1],R2,c,F):-                   % dom({[...],...},D) or dom({[...],...},{...}) or dom({[...],...},int(t1,t2))
         nonvar(S), S = SR with [A1,_A2], !,
         sunify(D,DR with A1,C),
         append(C,R1,R3),
-        sat_step([dom(SR,DR)|R3],R2,_,F).                                          
-sat_dom([dom(S,D)|R1],[dom(S,D)|R2],Stop,F):-     % dom(S,R) (irreducible form) 
-        var(S),var(D),!,                           
-        sat_step(R1,R2,Stop,F).                                                  
-sat_dom([dom(S,D)|R1],R2,c,F):-                   % dom(S,{t}) 
-        var(S), nonvar(D), D = E with A, nonvar(E), is_empty(E), !,                          
-        sat_step([comp({} with [A,A],R,R),S = R with [A,Z],[A,Z] nin R|R1],R2,_,F).   
+        sat_step([dom(SR,DR)|R3],R2,_,F).
+sat_dom([dom(S,D)|R1],[dom(S,D)|R2],Stop,F):-     % dom(S,R) (irreducible form)
+        var(S),var(D),!,
+        sat_step(R1,R2,Stop,F).
+sat_dom([dom(S,D)|R1],R2,c,F):-                   % dom(S,{t})
+        var(S), nonvar(D), D = E with A, nonvar(E), is_empty(E), !,
+        sat_step([comp({} with [A,A],R,R),S = R with [A,Z],[A,Z] nin R|R1],R2,_,F).
 sat_dom([dom(S,D)|R1],R2,c,F):-                   % dom(S,{t1,...,tn}), n > 1 or dom(S,{t1/R}),
-        var(S),nonvar(D), D = DR with A,!,                           
+        var(S),nonvar(D), D = DR with A,!,
         sat_step([dom(S1,{} with A),dom(S2,DR),disj(S1,S2),delay(un(S1,S2,S),false)|R1],R2,_,F).
 
 
 %%%%%%%%%%%%%%%%%%%%%% inverse of a binary relation (inv/2)
 
-sat_inv([inv(R,S)|R1],[inv(R,S)|R2],Stop,F):-     % inv(X,Y) (irreducible form) 
-        var(R),var(S),!,                           
+sat_inv([inv(R,S)|R1],[inv(R,S)|R2],Stop,F):-     % inv(X,Y) (irreducible form)
+        var(R),var(S),!,
         sat_step(R1,R2,Stop,F).
-sat_inv([inv(R,S)|R1],R2,c,F):-                   % inv({},S) 
-        nonvar(R),R={},!, 
+sat_inv([inv(R,S)|R1],R2,c,F):-                   % inv({},S)
+        nonvar(R),R={},!,
         sunify(S,{},C),
         append(C,R1,R3),
-        sat_step(R3,R2,_,F).                         
-sat_inv([inv(R,S)|R1],R2,c,F):-                   % inv(R,{}) 
-        nonvar(S),S={},!, 
+        sat_step(R3,R2,_,F).
+sat_inv([inv(R,S)|R1],R2,c,F):-                   % inv(R,{})
+        nonvar(S),S={},!,
         sunify(R,{},C),
         append(C,R1,R3),
-        sat_step(R3,R2,_,F).                         
-sat_inv([inv(R,S)|R1],R2,c,F):-                   % inv({...},S) or inv({...},{...})      
+        sat_step(R3,R2,_,F).
+sat_inv([inv(R,S)|R1],R2,c,F):-                   % inv({...},S) or inv({...},{...})
         nonvar(R), R = _ with [X,Y], !,
         sunify(R,RR with [X,Y],C1), append(C1,R1,C1R1),
         sunify(S,SR with [Y,X],C2), append(C1R1,C2,R3),
-        sat_step([[X,Y] nin RR,[Y,X] nin SR,inv(RR,SR)|R3],R2,_,F).                                          
-sat_inv([inv(R,S)|R1],R2,c,F):-                   % inv(R,{...})     
+        sat_step([[X,Y] nin RR,[Y,X] nin SR,inv(RR,SR)|R3],R2,_,F).
+sat_inv([inv(R,S)|R1],R2,c,F):-                   % inv(R,{...})
         var(R), nonvar(S), S = _ with [X,Y], !,
         sunify(S,SR with [X,Y],C1), append(C1,R1,R3),
         R = RR with [Y,X],
-        sat_step([[X,Y] nin SR,inv(RR,SR)|R3],R2,_,F).                                          
-                       
+        sat_step([[X,Y] nin SR,inv(RR,SR)|R3],R2,_,F).
+
 
 %%%%%%%%%%%%%%%%%%%%%% range of a binary relation (ran/2)
 
-%sat_ran2dom([ran(R,A)|R1],R2,c,F) :-                  
+%sat_ran2dom([ran(R,A)|R1],R2,c,F) :-
 %        sat_step([inv(R,S),dom(S,A)|R1],R2,_,F).
-                 
+
 %%%%%%%%%%%%%%%%%%%%%% range of a binary relation (ran/2)
 
 sat_ran([ran(X,Y)|R1],R2,c,F):-                   % ran(X,X)
-        var(X),var(Y),X==Y,!, X = {},                          
+        var(X),var(Y),X==Y,!, X = {},
         sat_step(R1,R2,_,F).
 sat_ran([ran(S,D)|R1],R2,c,F):-                   % ran({},r) or ran(int(a,b),r) with a>b
-        nonvar(S),is_empty(S),!, 
+        nonvar(S),is_empty(S),!,
         sunify(D,{},C),
         append(C,R1,R3),
-        sat_step(R3,R2,_,F).                         
+        sat_step(R3,R2,_,F).
 sat_ran([ran(S,D)|R1],R2,c,F):-                   % ran(S,{}) or ran(S,int(a,b)) with a>b
-        nonvar(D), is_empty(D),!, 
+        nonvar(D), is_empty(D),!,
         sunify(S,{},C),
         append(C,R1,R3),
-        sat_step(R3,R2,_,F).  
-sat_ran([ran(S,D)|R1],[ran(S,D)|R2],Stop,F):-     % ran(S,R) or ran(S,r) (irreducible forms) 
-        var(S), noran_elim,!,                           
+        sat_step(R3,R2,_,F).
+sat_ran([ran(S,D)|R1],[ran(S,D)|R2],Stop,F):-     % ran(S,R) or ran(S,r) (irreducible forms)
+        var(S), noran_elim,!,
         sat_step(R1,R2,Stop,F).
 sat_ran([ran(S,D)|R1],R2,c,F):-                   % ran({[...],...},R) or ran({[...],...},{...}) or ran({[...],...},int(t1,t2))
         nonvar(S), S = SR with [_A1,A2], noran_elim,!,
         sunify(D,DR with A2,C),
         append(C,R1,R3),
-        (var(SR),nonvar(DR), DR=_ with _,!,                      
-         sat_step([solved(ran(SR,DR),var(SR),[],f)|R3],R2,_,F)   
+        (var(SR),nonvar(DR), DR=_ with _,!,
+         sat_step([solved(ran(SR,DR),var(SR),[],f)|R3],R2,_,F)
          ;
-         sat_step([ran(SR,DR)|R3],R2,_,F)                     
+         sat_step([ran(SR,DR)|R3],R2,_,F)
         ).
-sat_ran([ran(S,D)|R1],[ran(S,D)|R2],Stop,F):-     % ran(S,R) (irreducible form) 
-        var(S),var(D),!,                           
-        sat_step(R1,R2,Stop,F).                                                
-sat_ran([ran(S,D)|R1],R2,c,F):-                   % ran(S,{t}) 
-        var(S), nonvar(D), D = E with A, nonvar(E), is_empty(E), !,                          
-        sat_step([comp(R,{} with [A,A],R),S = R with [Z,A],[Z,A] nin R|R1],R2,_,F).  
+sat_ran([ran(S,D)|R1],[ran(S,D)|R2],Stop,F):-     % ran(S,R) (irreducible form)
+        var(S),var(D),!,
+        sat_step(R1,R2,Stop,F).
+sat_ran([ran(S,D)|R1],R2,c,F):-                   % ran(S,{t})
+        var(S), nonvar(D), D = E with A, nonvar(E), is_empty(E), !,
+        sat_step([comp(R,{} with [A,A],R),S = R with [Z,A],[Z,A] nin R|R1],R2,_,F).
 sat_ran([ran(S,D)|R1],R2,c,F):-                   % ran(S,{t1,...,tn}), n > 1 or  ran(S,{t1/R}),
-        var(S),nonvar(D),D = DR with A,!,                           
-        sat_step([ran(S1,{} with A),ran(S2,DR),disj(S1,S2),delay(un(S1,S2,S),false)|R1],R2,_,F).                       
+        var(S),nonvar(D),D = DR with A,!,
+        sat_step([ran(S1,{} with A),ran(S2,DR),disj(S1,S2),delay(un(S1,S2,S),false)|R1],R2,_,F).
 sat_ran([ran(S,D)|R1],R2,c,F):-                   % ran({[...],...},R) or ran({[...],...},{...}) or ran({[...],...},int(t1,t2))
         nonvar(S), S = SR with [_A1,A2],!,
         sunify(D,DR with A2,C),
         append(C,R1,R3),
-        sat_step([ran(SR,DR)|R3],R2,_,F) .                  
+        sat_step([ran(SR,DR)|R3],R2,_,F) .
 
 
-%%%%%%%%%%%%%%%%%%%%%% composition of binary relations (comp/3)  
+%%%%%%%%%%%%%%%%%%%%%% composition of binary relations (comp/3)
 
 sat_comp([comp(R,_S,T)|R1],R2,c,F):-             % comp({},s,t) or comp(int(a,b),s,t) with a>b
-        nonvar(R),is_empty(R),!, 
+        nonvar(R),is_empty(R),!,
         sunify(T,{},C),
         append(C,R1,R3),
-        sat_step(R3,R2,_,F).                         
+        sat_step(R3,R2,_,F).
 sat_comp([comp(_R,S,T)|R1],R2,c,F):-             % comp(r,{},t) or comp(r,int(a,b),t) with a>b
-        nonvar(S),is_empty(S),!, 
+        nonvar(S),is_empty(S),!,
         sunify(T,{},C),
         append(C,R1,R3),
-        sat_step(R3,R2,_,F).    
+        sat_step(R3,R2,_,F).
 sat_comp([comp(R,S,T)|R1],R2,c,F):-              % comp(r,s,{}) or comp(r,s,int(a,b)) with a>b
-        nonvar(T),is_empty(T),!, 
-        sat_step([ran(R,RR),dom(S,DS),disj(RR,DS)|R1],R2,_,F).                         
-sat_comp([comp(R,S,T)|R1],[comp(R,S,T)|R2],Stop,F):-  
-        (var(R),var(T),! ; var(S),var(T)),!,     % comp(R,s,T) or comp(r,S,T), r and s not empty set,                        
-        sat_step(R1,R2,Stop,F).                  % irreducible forms                        
-
-sat_comp([comp(R,S,Q)|CR1],CR2,c,F):-            % special case: comp({[A,A]},{[X,Z]/N},{[X,Z]/N}), var(N)     
-        nonvar(R), R = {} with [A,A], 
+        nonvar(T),is_empty(T),!,
+        sat_step([ran(R,RR),dom(S,DS),disj(RR,DS)|R1],R2,_,F).
+sat_comp([comp(R,S,T)|R1],[comp(R,S,T)|R2],Stop,F):-
+        (var(R),var(T),! ; var(S),var(T)),!,     % comp(R,s,T) or comp(r,S,T), r and s not empty set,
+        sat_step(R1,R2,Stop,F).                  % irreducible forms
+
+sat_comp([comp(R,S,Q)|CR1],CR2,c,F):-            % special case: comp({[A,A]},{[X,Z]/N},{[X,Z]/N}), var(N)
+        nonvar(R), R = {} with [A,A],
         nonvar(S), S = N with [X,_], var(N), var(X),
-        nonvar(Q), Q = S,!,                      
-        X = A,            
-        sat_step([comp({} with [A,A],N,N) | CR1],CR2,_,F). 
-sat_comp([comp(R,S,Q)|CR1],CR2,c,F):-            % special case: comp({[X,Z]/N},{[A,A]},{[X,Z]/N}), var(N)     
+        nonvar(Q), Q = S,!,
+        X = A,
+        sat_step([comp({} with [A,A],N,N) | CR1],CR2,_,F).
+sat_comp([comp(R,S,Q)|CR1],CR2,c,F):-            % special case: comp({[X,Z]/N},{[A,A]},{[X,Z]/N}), var(N)
         nonvar(R), R = N with [_,Y], var(N), var(Y),
-        nonvar(S), S = {} with [A,A], 
-        nonvar(Q), Q = R,!,                      
-        Y = A,         
-        sat_step([comp(N,{} with [A,A],N) | CR1],CR2,_,F). 
-  
-sat_comp([comp(R,S,Q)|CR1],CR2,c,F):-            % comp(R,S,{[X,Z]}), var(R), var(S)     
-        nonvar(Q), var(R), var(S), 
+        nonvar(S), S = {} with [A,A],
+        nonvar(Q), Q = R,!,
+        Y = A,
+        sat_step([comp(N,{} with [A,A],N) | CR1],CR2,_,F).
+
+sat_comp([comp(R,S,Q)|CR1],CR2,c,F):-            % comp(R,S,{[X,Z]}), var(R), var(S)
+        nonvar(Q), var(R), var(S),
         Q = QQ with [X,Z], nonvar(QQ), is_empty(QQ), !,
         sat_step([un(R1,R2,R),un(S1,S2,S),disj(R1,R2),disj(S1,S2),
                   dom(R1,{} with X),ran(S1,{} with Z),
-                  ran(R1,A1),dom(S1,B1),A1=B1,    
+                  ran(R1,A1),dom(S1,B1),A1=B1,
                   dom(S2,B2),ran(R2,A2),
-                  disj(A1,B2),disj(A2,B1),disj(A2,B2) | CR1],CR2,_,F). 
-sat_comp([comp(R,S,T)|R1],R2,c,F):-              % comp(r,s,{[X,Y],...})      
+                  disj(A1,B2),disj(A2,B1),disj(A2,B2) | CR1],CR2,_,F).
+sat_comp([comp(R,S,T)|R1],R2,c,F):-              % comp(r,s,{[X,Y],...})
         nonvar(T), T = _ with [X,Z], !,
         sunify(R,RR with [X,Y],C1),
         sunify(S,SR with [Y,Z],C2),
@@ -3493,27 +3493,27 @@ sat_comp([comp(R,S,T)|R1],R2,c,F):-              % comp(r,s,{[X,Y],...})
                   comp({} with [X,Y],SR,Q1),
                   comp(RR,{} with [Y,Z],Q2),
                   comp(RR,SR,Q3), Q11 = Q1 with [X,Z],
-                  un(Q11,Q2,Q1_2),un(Q1_2,Q3,T), 
-                  disj(Q11,Q2),disj(Q1_2,Q3) | R3],R2,_,F).   
- 
-sat_comp([comp(R,S,T)|R1],R2,c,F):-              % comp({[X,Y]},{[Z,V]},T), T var.     
+                  un(Q11,Q2,Q1_2),un(Q1_2,Q3,T),
+                  disj(Q11,Q2),disj(Q1_2,Q3) | R3],R2,_,F).
+
+sat_comp([comp(R,S,T)|R1],R2,c,F):-              % comp({[X,Y]},{[Z,V]},T), T var.
         var(T),
-        nonvar(R), R = {} with [X,Y],           
-        nonvar(S), S = {} with [Y,Z],   
+        nonvar(R), R = {} with [X,Y],
+        nonvar(S), S = {} with [Y,Z],
         T = {} with [X,Z],
-        sat_step(R1,R2,_,F).    
-sat_comp([comp(R,S,T)|R1],R2,c,F):-              % comp({[X,Y],...},{...},T), T var.  
-        var(T),                                  % forall(Z,[Y,Z] nin S)    
+        sat_step(R1,R2,_,F).
+sat_comp([comp(R,S,T)|R1],R2,c,F):-              % comp({[X,Y],...},{...},T), T var.
+        var(T),                                  % forall(Z,[Y,Z] nin S)
         nonvar(R), R = {} with [_X,Y],
-        nonvar(S), S = {} with [_Y,_Z],!, 
-        T = {},                     
-        sat_step([dom(S,DS),Y nin DS|R1],R2,_,F). 
-                                    
-sat_comp([comp(R,S,T)|R1],R2,c,F):-              % comp({[X,Y],...},{...},T), T var.     
+        nonvar(S), S = {} with [_Y,_Z],!,
+        T = {},
+        sat_step([dom(S,DS),Y nin DS|R1],R2,_,F).
+
+sat_comp([comp(R,S,T)|R1],R2,c,F):-              % comp({[X,Y],...},{...},T), T var.
         var(T),!,
         comp_distribute(R,S,C,{},T),
         append(C,R1,R3),
-        sat_step(R3,R2,_,F).    
+        sat_step(R3,R2,_,F).
 
 comp_distribute(R,S,C,T0,T) :-
         var(R),!,
@@ -3538,97 +3538,97 @@ comp_distribute_first(P1,SR with P2,C,T0,T) :-
 comp_distribute_first(P1,SR with P2,C,T0,T) :-
         C = [comp({} with P1,{} with P2,T1),un(T0,T1,T2) | CR],
         comp_distribute_first(P1,SR,CR,T2,T).
-         
 
-%%%%%%%%%%%%%%%%%%%%%% domain of partial function (dompf/2) 
+
+%%%%%%%%%%%%%%%%%%%%%% domain of partial function (dompf/2)
 
 sat_dompf([dompf(X,Y)|R1],R2,c,F):-                   % dom(X,X)
-        var(X),var(Y),X==Y,!, X = {},                          
+        var(X),var(Y),X==Y,!, X = {},
         sat_step(R1,R2,_,F).
-sat_dompf([dompf(S,D)|R1],[dompf(S,D)|R2],Stop,F):-   % dom(S,D) (irreducible form) 
-        var(S),var(D),!,            
+sat_dompf([dompf(S,D)|R1],[dompf(S,D)|R2],Stop,F):-   % dom(S,D) (irreducible form)
+        var(S),var(D),!,
         sat_step(R1,R2,Stop,F).
 sat_dompf([dompf(S,D)|R1],R2,c,F):-                   % dom({},d) or dom(int(a,b),d) with a>b
-        nonvar(S),is_empty(S),!, 
+        nonvar(S),is_empty(S),!,
         sunify(D,{},C),
         append(C,R1,R3),
-        sat_step(R3,R2,_,F).                         
+        sat_step(R3,R2,_,F).
 sat_dompf([dompf(S,D)|R1],R2,c,F):-                   % dom(s,{}) or dom(s,int(a,b)) with a>b
-        nonvar(D),is_empty(D),!, 
+        nonvar(D),is_empty(D),!,
         sunify(S,{},C),
         append(C,R1,R3),
-        sat_step(R3,R2,_,F).                      
-sat_dompf([dompf(S,D)|R1],R2,c,F):-                   % dom({[...],...},D) or dom({[...],...},{...}) or dom({[...],...},int(t1,t2))      
+        sat_step(R3,R2,_,F).
+sat_dompf([dompf(S,D)|R1],R2,c,F):-                   % dom({[...],...},D) or dom({[...],...},{...}) or dom({[...],...},int(t1,t2))
         nonvar(S), S = SR with [A1,_A2], !,
         sunify(D,DR with A1,C),
         append(C,R1,R3),
-        sat_step([dompf(SR,DR)|R3],R2,_,F).                      
+        sat_step([dompf(SR,DR)|R3],R2,_,F).
 sat_dompf([dompf(S,D)|R1],R2,c,F):-                   % dom(S,int(a,a)), var(S)
         var(S), nonvar(D), is_int(D,A,B), A==B,!,
         S = {} with [A,_],
-        sat_step(R1,R2,_,F).                         
+        sat_step(R1,R2,_,F).
 sat_dompf([dompf(S,D)|R1],R2,c,F):-                   % dom(S,int(a,b)), var(S)
         var(S), nonvar(D), is_int(D,A,B), A<B,!,
         S = SR with [A,_],
         A1 is A + 1,
-        sat_step([dompf(SR,int(A1,B))|R1],R2,_,F).                           
+        sat_step([dompf(SR,int(A1,B))|R1],R2,_,F).
 sat_dompf([dompf(S,D)|R1],R2,c,F):-                   % dom(S,{...}) or dom(S,int(A,B)), var(S)
         var(S), nonvar(D),
         sunify(D,DR with A1,C),!,
         S = SR with [A1,_A2],
         append(C,R1,R3),
-        sat_step([dompf(SR,DR)|R3],R2,_,F).  
-%        sat_step([A1 nin DR,dompf(SR,DR)|R3],R2,_,F). 
+        sat_step([dompf(SR,DR)|R3],R2,_,F).
+%        sat_step([A1 nin DR,dompf(SR,DR)|R3],R2,_,F).
 
 
-%%%%%%%%%%%%%%%%%%%%%% composition of partial functions (comppf/3) 
+%%%%%%%%%%%%%%%%%%%%%% composition of partial functions (comppf/3)
 
 sat_comppf([comppf(R,_S,T)|R1],R2,c,F):-         % comppf({},s,t) or comppf(int(a,b),s,t) with a>b
-        nonvar(R),is_empty(R),!, 
+        nonvar(R),is_empty(R),!,
         sunify(T,{},C),
         append(C,R1,R3),
-        sat_step(R3,R2,_,F).                         
+        sat_step(R3,R2,_,F).
 sat_comppf([comppf(_R,S,T)|R1],R2,c,F):-         % comppf(r,{},t) or comppf(r,int(a,b),t) with a>b
-        nonvar(S),is_empty(S),!, 
+        nonvar(S),is_empty(S),!,
         sunify(T,{},C),
         append(C,R1,R3),
-        sat_step(R3,R2,_,F).    
+        sat_step(R3,R2,_,F).
 sat_comppf([comppf(R,S,T)|R1],R2,c,F):-          % comppf(r,s,{}) or comppf(r,s,int(a,b)) with a>b
-        nonvar(T),is_empty(T),!, 
-        sat_step([ran(R,RR),dompf(S,DS),disj(RR,DS)|R1],R2,_,F).                         
-sat_comppf([comppf(R,S,T)|R1],[comppf(R,S,T)|R2],Stop,F):-  
-        var(R),var(T),!,                         % comppf(R,s,T), s not empty set,                        
-        sat_step(R1,R2,Stop,F).                  % irreducible forms                        
-sat_comppf([comppf(R,S,T)|R1],R2,c,F):-          % comppf(r,s,{[X,Y],...})      
+        nonvar(T),is_empty(T),!,
+        sat_step([ran(R,RR),dompf(S,DS),disj(RR,DS)|R1],R2,_,F).
+sat_comppf([comppf(R,S,T)|R1],[comppf(R,S,T)|R2],Stop,F):-
+        var(R),var(T),!,                         % comppf(R,s,T), s not empty set,
+        sat_step(R1,R2,Stop,F).                  % irreducible forms
+sat_comppf([comppf(R,S,T)|R1],R2,c,F):-          % comppf(r,s,{[X,Y],...})
         nonvar(T), T = _ with [X,Y], !,
-        sunify(T,RT with [X,Y],C0),              
+        sunify(T,RT with [X,Y],C0),
         sunify(R,RR with [X,Z],C1),
         sunify(S,RS with [Z,Y],C2),
         append(C0,C1,C01),
         append(C01,C2,C012),
         append(C012,R1,R3),
-        sat_step([[X,Y] nin RT,[X,Z] nin RR,[Z,Y] nin RS,comppf(RR,S,RT)|R3],R2,_,F).                                              
-sat_comppf([comppf(R,S,T)|R1],R2,c,F):-          % comppf({[X,Y],...},{...},t), t var.     
+        sat_step([[X,Y] nin RT,[X,Z] nin RR,[Z,Y] nin RS,comppf(RR,S,RT)|R3],R2,_,F).
+sat_comppf([comppf(R,S,T)|R1],R2,c,F):-          % comppf({[X,Y],...},{...},t), t var.
         R = RR with [X,Y],           % exists(Z,[Y,Z] in S)
-        sunify(S,SR with [Y,Z],C),   
+        sunify(S,SR with [Y,Z],C),
         T = TR with [X,Z],
         append(C,R1,R3),
-        sat_step([[Y,Z] nin SR,comppf(RR,S,TR)|R3],R2,_,F). 
-sat_comppf([comppf(R,S,T)|R1],R2,c,F):-          % comppf({[X,Y],...},{...},t), t var.      
+        sat_step([[Y,Z] nin SR,comppf(RR,S,TR)|R3],R2,_,F).
+sat_comppf([comppf(R,S,T)|R1],R2,c,F):-          % comppf({[X,Y],...},{...},t), t var.
         R = RR with [_X,Y],                      % forall(Z,[Y,Z] nin S)
-        sat_step([dompf(S,DS),Y nin DS,comppf(RR,S,T)|R1],R2,_,F). 
+        sat_step([dompf(S,DS),Y nin DS,comppf(RR,S,T)|R1],R2,_,F).
 
 
 %%%%%%%%%%%%%%%%%%%%%% domain restriction (dres/3)
-                        
+
 sat_dres([dres(A,R,S)|R1],R2,Stop,nf) :-             % dres(A,R,S), A,R,S variables: delayed
         var(A), var(R), var(S), !,
-        sat_step([delay(dres(A,R,S),novar3(A,R,S)) | R1],R2,Stop,nf).   
+        sat_step([delay(dres(A,R,S),novar3(A,R,S)) | R1],R2,Stop,nf).
 sat_dres([dres(A,R,S)|R1],R2,c,F):-                 % dres(A,R,S)
-        sat_step([un(S,T,R),set(T),dom(S,B),set(B),subset(B,A),dom(T,C),set(C),disj(A,C)|R1],R2,_,F).   
+        sat_step([un(S,T,R),set(T),dom(S,B),set(B),subset(B,A),dom(T,C),set(C),disj(A,C)|R1],R2,_,F).
 
 sat_drespf([drespf(A,R,S)|R1],R2,c,F):-             % drespf(A,R,S) -  only for partial functions
-        sat_step([dom(R,DR),set(DR),inters(A,DR,I),subset(S,R),dom(S,I)|R1],R2,_,F).                          
+        sat_step([dom(R,DR),set(DR),inters(A,DR,I),subset(S,R),dom(S,I)|R1],R2,_,F).
 
 novar3(A,_R,_S) :- nonvar(A),!.
 novar3(_A,R,_S) :- nonvar(R),!.
@@ -3636,20 +3636,20 @@ novar3(_A,_R,S) :- nonvar(S).
 
 %%%%%%%%%%%%%%%%%%%%%% range restriction (rres/3)
 
-sat_rres([rres(B,R,S)|R1],R2,c,F):-               
+sat_rres([rres(B,R,S)|R1],R2,c,F):-
         sat_step([un(S,T,R),ran(S,RS),ran(R,RR),inters(B,RR,RS),
-                  ran(T,RT),disj(RS,RT)|R1],R2,_,F).  
+                  ran(T,RT),disj(RS,RT)|R1],R2,_,F).
 
 
 %%%%%%%%%%%%%%%%%%%%%% domain anti-restriction (ndres/3)
 
 sat_ndres([ndres(A,R,S)|R1],R2,Stop,nf) :-         %  ndres(A,R,S), A,R,S variables: delayed
         var(A), var(R), var(S), !,
-        sat_step([delay(ndres(A,R,S),novar3(A,R,S)) | R1],R2,Stop,nf).                         
+        sat_step([delay(ndres(A,R,S),novar3(A,R,S)) | R1],R2,Stop,nf).
 sat_ndres([ndres(A,R,S)|R1],R2,c,F) :-             % ndres(A,R,S)
         sat_step([dres(A,R,B),
                   subset(S,R),un(B,S,D),subset(R,D),disj(B,S)    % diff(R,B,S)
-                 |R1],R2,_,F).                         
+                 |R1],R2,_,F).
 
 
 %%%%%%%%%%%%%%%%%%%%%% range anti-restriction (nrres/3)
@@ -3657,13 +3657,13 @@ sat_ndres([ndres(A,R,S)|R1],R2,c,F) :-             % ndres(A,R,S)
 sat_nrres([nrres(A,R,S)|R1],R2,c,F):-            % nrres(A,R,S)
         sat_step([rres(A,R,B),
                  subset(S,R),un(B,S,D),subset(R,D),disj(B,S)    % diff(R,B,S)
-                 |R1],R2,_,F).   
+                 |R1],R2,_,F).
 
 
 %%%%%%%%%%%%%%%%%%%%%% partial function application (apply/3)
 
 sat_apply([apply(S,X,Y)|R1],R2,c,F):-            % apply(F,X,Y)
-        sat_step([[X,Y] in S|R1],R2,_,F).                         
+        sat_step([[X,Y] in S|R1],R2,_,F).
 
 
 %%%%%%%%%%%%%%%%%%%%%% not partial function (npfun/1)
@@ -3672,12 +3672,12 @@ sat_npfun([npfun(X)|R1],R2,c,F):-                % npfun(X)
         (sat_step([set(X), [N1,N2] in X, [N1,N3] in X, N2 neq N3 |R1],R2,_,F)
          ;
          sat_step([nrel(X) |R1],R2,_,F)
-        ).   
+        ).
 
 %%%%%%%%%%%%%%%%%%%%%% not binary relation (nrel/1)
 
 sat_nrel([nrel(X)|R1],R2,c,F):-                  % nrel(X)
-        sat_step([set(X), N in X, npair(N) |R1],R2,_,F).  
+        sat_step([set(X), N in X, npair(N) |R1],R2,_,F).
 
 
 %%%%%%%%%%%%%%%%%%%%%% not pair (npair/1)
@@ -3685,12 +3685,12 @@ sat_nrel([nrel(X)|R1],R2,c,F):-                  % nrel(X)
 sat_npair([npair(X)|R1],[npair(X)|R2],Stop,F):-  % npair(X), var(X), (irreducible form)
         var(X),!,
         sat_step(R1,R2,Stop,F).
-sat_npair([npair(X)|R1],R2,c,F):-                % npair(f(a,b)) 
+sat_npair([npair(X)|R1],R2,c,F):-                % npair(f(a,b))
         functor(X,Funct,Arity),
         (Funct \== '[|]',! ; Arity \== 2),!,
         sat_step(R1,R2,_,F).
 sat_npair([npair(X)|R1],R2,c,F):-                % npair([a]) or npair([a,b,c,...])
-        functor(X,'[|]',2), 
+        functor(X,'[|]',2),
         length(X,M), M \== 2,
         sat_step(R1,R2,_,F).
 
@@ -3699,28 +3699,28 @@ sat_npair([npair(X)|R1],R2,c,F):-                % npair([a]) or npair([a,b,c,..
 %%%%%%%%%%%% Rewriting rules for control constraints %%%%%%%%%%%%
 %%%%%%%%%%%%
 
-%%%%%%%%%%%%%%%%%%%%%%% delay mechanism               
+%%%%%%%%%%%%%%%%%%%%%%% delay mechanism
 
-sat_delay([delay(irreducible(A) & true,G)|R1],R2,c,f) :- 
+sat_delay([delay(irreducible(A) & true,G)|R1],R2,c,f) :-
         final,
         solve_goal(G,C1),!,
         solve_goal(A,C2),
         append(C1,C2,C3),
         append(C3,R1,R3),
         sat_step(R3,R2,_,f).
-sat_delay([delay(irreducible(A) & true,G)|R1],[delay(irreducible(A) & true,G)|R2],Stop,f) :- 
+sat_delay([delay(irreducible(A) & true,G)|R1],[delay(irreducible(A) & true,G)|R2],Stop,f) :-
         final, !,
         sat_step(R1,R2,Stop,f).
 
-sat_delay([delay(A,_G)|R1],R2,c,f) :- 
+sat_delay([delay(A,_G)|R1],R2,c,f) :-
         final, !,
         solve_goal_nodel(A,C2),
         append(C2,R1,R3),
         sat_step(R3,R2,_,f).
 
-sat_delay([delay(A,G)|R1],R2,c,F) :- 
+sat_delay([delay(A,G)|R1],R2,c,F) :-
         solve_goal(G,C1),!,
-        sat_delay_atom(A,A1),    
+        sat_delay_atom(A,A1),
         solve_goal(A1,C2),
         append(C1,C2,C3),
         append(C3,R1,R3),
@@ -3735,12 +3735,12 @@ sat_delay_atom(A,A).
 %%%Solve goal G without generating any new delay
 solve_goal_nodel(G,ClistNew) :-
        constrlist(G,GClist,GAlist),
-       solve_goal_nodel(GClist,GAlist,ClistNew). 
+       solve_goal_nodel(GClist,GAlist,ClistNew).
 
-solve_goal_nodel(Clist,[],CListCan):- !, 
-       sat(Clist,CListCan,f). 
-solve_goal_nodel(Clist,[true],CListCan):- !, 
-       sat(Clist,CListCan,f). 
+solve_goal_nodel(Clist,[],CListCan):- !,
+       sat(Clist,CListCan,f).
+solve_goal_nodel(Clist,[true],CListCan):- !,
+       sat(Clist,CListCan,f).
 solve_goal_nodel(Clist,[A|B],CListOut):-
        sat(Clist,ClistSolved,f),
        sat_or_solve(A,ClistSolved,ClistNew,AlistCl,f),
@@ -3748,46 +3748,46 @@ solve_goal_nodel(Clist,[A|B],CListOut):-
        solve_goal_nodel(ClistNew,AlistNew,CListOut).
 
 
-%%%%%%%%%%%%%%%%%%%%%%% solved mechanism              
+%%%%%%%%%%%%%%%%%%%%%%% solved mechanism
 
-% solved(C,G,Lev,Mode): constraint C is considered solved (i.e. not 
+% solved(C,G,Lev,Mode): constraint C is considered solved (i.e. not
 % further processed) at solver level Lev, while goal G is true;
 % in final mode, if Mode is 'nf', the constraint C is anyway
 % considered no longer solved
 
 sat_solved([solved(C,G,Lev,Mode)|R1],R2,R,F):-
-       call(G),!, 
+       call(G),!,
        test_final([solved(C,G,Lev,Mode)|R1],R2,R,F).
-sat_solved([solved(C,_,_,_)|R1],R2,c,F):-     
+sat_solved([solved(C,_,_,_)|R1],R2,c,F):-
        sat_step([C|R1],R2,_,F).
 
 test_final([solved(C,G,Lev,Mode)|R1],[solved(C,G,Lev,Mode)|R2],Stop,nf) :- !,
        sat_step(R1,R2,Stop,nf).
-test_final([solved(C,G,Lev,Mode)|R1],[solved(C,G,Lev,Mode)|R2],Stop,f) :- 
+test_final([solved(C,G,Lev,Mode)|R1],[solved(C,G,Lev,Mode)|R2],Stop,f) :-
        Mode == f,!,                            % final sat: G is true and in final mode
        sat_step(R1,R2,Stop,f).                 %  --> mantain solved
 test_final([solved(C,_,_,_)|R1],R2,c,f) :-     % final sat: G is true and not in final mode
        sat_step([C|R1],R2,_,f).                %  --> remove solved
 
-      
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%      Level 2     %%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%  Check pairs of constraints   %%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-     
+
 global_check([],_,[],_) :- !.
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%% type clashes
 
-global_check([C|RC],GC,[C|NewC],F) :-   % type clashes --> fail  
+global_check([C|RC],GC,[C|NewC],F) :-   % type clashes --> fail
     type_constr(C),!,
-    \+type_err(C,RC),   
+    \+type_err(C,RC),
     global_check(RC,GC,NewC,F).
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%% neq elimination
 %%%%%%%%%%%%%%%%%%%%%%%%%%%% (X neq t and X a set variable) (only in final mode)
 
-global_check([C|RC],GC,NewC,f) :-       % neq: W neq T and W or T set variables 
+global_check([C|RC],GC,NewC,f) :-       % neq: W neq T and W or T set variables
     is_neq(C,1,W,T),
     var(W), var(T),
     find_setconstraint(W,T,GC,X,Y),!,
@@ -3837,24 +3837,24 @@ global_check([C|RC],GC,NewC,F) :-       % un-un: un(X,Y,Z1) & un(Y,X,Z2) --> un(
     global_check(RC,GC,NewC1,F).
 
 global_check([C|RC],GC,NewC,F) :-       % size-size: size(S,N) & size(S,M) ---> size(S,M) & N=M
-    is_size(C,1,X,N), 
-    var(X),                                              
+    is_size(C,1,X,N),
+    var(X),
     find_size(X,RC,M),!,
     trace_irules('size-size'),
     N = M,
     global_check(RC,GC,NewC,F).
 
 global_check([C|RC],GC,NewC,F) :-       % min-min: min(S,N) & min(S,M) ---> min(S,M) & N=M
-    is_min(C,1,X,N),                   
-    var(X), 
+    is_min(C,1,X,N),
+    var(X),
     find_min(X,RC,M),!,
     trace_irules('min-min'),
     N = M,
     global_check(RC,GC,NewC,F).
 
 global_check([C|RC],GC,NewC,F) :-       % max-max: max(S,N) & max(S,M) ---> max(S,M) & N=M
-    is_max(C,1,X,N),                 
-    var(X),                        
+    is_max(C,1,X,N),
+    var(X),
     find_max(X,RC,M),!,
     trace_irules('max-max'),
     N = M,
@@ -3869,49 +3869,49 @@ global_check([C|RC],GC,NewC,F) :-       % sum-sum: sum(S,N) & sum(S,M) ---> sum(
     global_check(RC,GC,NewC,F).
 
                                         % dom-neq: dom(S,D) & D neq {} --> dom(S,D) & D neq {} & S neq {}
-global_check([C|RC],GC,AddedC,F) :-    
-    is_dom_l(C,L,S,D,RorF), 
-    var(S),var(D),\+member(1,L),           
-    find_neq(D,GC),!,   
+global_check([C|RC],GC,AddedC,F) :-
+    is_dom_l(C,L,S,D,RorF),
+    var(S),var(D),\+member(1,L),
+    find_neq(D,GC),!,
     trace_irules('dom-neq_dom'),
     add_dom_neq(RorF,S,D,AddedC,L,NewC),
     global_check(RC,GC,NewC,F).
                                         % dom-neq: dom(S,D) & S neq {} --> dom(S,D) & D neq {} & S neq {}
-global_check([C|RC],GC,AddedC,F) :-    
-    is_dom_l(C,L,S,D,RorF), 
-    var(S),var(D),\+member(1,L),           
-    find_neq(S,GC),!,    
+global_check([C|RC],GC,AddedC,F) :-
+    is_dom_l(C,L,S,D,RorF),
+    var(S),var(D),\+member(1,L),
+    find_neq(S,GC),!,
     trace_irules('dom-neq_rel'),
     add_dom_neqd(RorF,S,D,AddedC,L,NewC),
     global_check(RC,GC,NewC,F).
                                         % ran-neq: ran(S,D) & D neq {} --> ran(S,D) & D neq {} & S neq {}
-global_check([C|RC],GC,[solved(ran(S,D),(var(S),var(D)),[1|L],f),S neq {}|NewC],F) :-    
-    is_ran_l(C,L,S,D), 
+global_check([C|RC],GC,[solved(ran(S,D),(var(S),var(D)),[1|L],f),S neq {}|NewC],F) :-
+    is_ran_l(C,L,S,D),
     var(S),var(D),\+member(1,L),
-    find_neq(D,GC),!,          
+    find_neq(D,GC),!,
     trace_irules('ran_var-neq_ran'),
     global_check(RC,GC,NewC,F).
                                         % ran-neq: ran(S,{...}) --> ran(S,{...}) & S neq {}
-global_check([C|RC],GC,[solved(ran(S,D),var(S),[],f),S neq {}|NewC],F) :-   
+global_check([C|RC],GC,[solved(ran(S,D),var(S),[],f),S neq {}|NewC],F) :-
     C = ran(S,D),
-    var(S), nonvar(D), noran_elim,!,          
+    var(S), nonvar(D), noran_elim,!,
     trace_irules('ran_nonvar-neq_ran'),
     global_check(RC,GC,NewC,F).
                                         % ran-neq: ran(S,D) & S neq {} --> ran(S,D) & D neq {} & S neq {}
-global_check([C|RC],GC,[solved(ran(S,D),var(S),[1|L],f),D neq {}|NewC],F) :-    
-    is_ran_l(C,L,S,D), 
-    var(S),var(D),\+member(1,L),           
-    find_neq(S,GC),!,    
+global_check([C|RC],GC,[solved(ran(S,D),var(S),[1|L],f),D neq {}|NewC],F) :-
+    is_ran_l(C,L,S,D),
+    var(S),var(D),\+member(1,L),
+    find_neq(S,GC),!,
     trace_irules('ran-neq_rel'),
     global_check(RC,GC,NewC,F).
-                                        % un-size:  e.g., un(X,Y,Z) & size(Z,N) -+-> 
-                                        %                 size(X,NX) & size(Y,NY) & size(Z,NZ) & 
+                                        % un-size:  e.g., un(X,Y,Z) & size(Z,N) -+->
+                                        %                 size(X,NX) & size(Y,NY) & size(Z,NZ) &
                                         %                 NX =< NZ & NY =< NZ &NX + NY >= NZ
-global_check([C|RC],GC,[solved(un(X,Y,Z),(var(X),var(Y),var(Z)),[1|L],f),   
+global_check([C|RC],GC,[solved(un(X,Y,Z),(var(X),var(Y),var(Z)),[1|L],f),
                         size(X,NX),size(Y,NY),size(Z,NZ),
-                        integer(NX),integer(NY),integer(NZ)|NewC],F) :-    
-    is_un_l(C,L,X,Y,Z),                  
-    var(X), var(Y), var(Z),            
+                        integer(NX),integer(NY),integer(NZ)|NewC],F) :-
+    is_un_l(C,L,X,Y,Z),
+    var(X), var(Y), var(Z),
     \+member(1,L), find_size3(X,Y,Z,GC,_),!,
     trace_irules('un-size'),
     solve_FD(NX =< NZ),
@@ -3920,18 +3920,18 @@ global_check([C|RC],GC,[solved(un(X,Y,Z),(var(X),var(Y),var(Z)),[1|L],f),
     global_check(RC,GC,NewC,F).
 
                                          % dompf-size: e.g., dompf(S,D) & size(S,N) -+-> size(D,N)
-global_check([C|RC],GC,[solved(dompf(S,D),(var(S),var(D)),[2|L],f),   
-                        size(S,N),size(D,N),integer(N)|NewC],F) :-    
-    is_dom_l(C,L,S,D,pfun),  
-    var(S),var(D),\+member(2,L),          
+global_check([C|RC],GC,[solved(dompf(S,D),(var(S),var(D)),[2|L],f),
+                        size(S,N),size(D,N),integer(N)|NewC],F) :-
+    is_dom_l(C,L,S,D,pfun),
+    var(S),var(D),\+member(2,L),
     find_size2(S,D,GC,N),!,
     trace_irules('dom-size'),
     global_check(RC,GC,NewC,F).
 
                                          % ran-size: e.g., ran(S,R) & size(S,N) -+-> size(R,M) & M =< N
-global_check([C|RC],GC,AddedC,F) :-    
+global_check([C|RC],GC,AddedC,F) :-
     is_ran_l(C,L,S,R),
-    var(S),var(R),\+member(2,L),            
+    var(S),var(R),\+member(2,L),
     find_size2(S,R,GC,_),!,
     trace_irules('ran-size'),
     solve_FD(M =< N),
@@ -3939,37 +3939,37 @@ global_check([C|RC],GC,AddedC,F) :-
     global_check(RC,GC,NewC,F).
 
                                          % in-nin: T in X & T1 nin X (X is a list) --> T neq T1
-global_check([solved(T in X,G,3,f)|RC],GC,                        
+global_check([solved(T in X,G,3,f)|RC],GC,
              [solved(T in X,G,2,f),T neq T1|NewC],F) :- % called only after executing level 3 rules
-    find_nin(X,GC,T1),!,                                                   
-    global_check(RC,GC,NewC,F). 
+    find_nin(X,GC,T1),!,
+    global_check(RC,GC,NewC,F).
 
-                                         % int-not empty: int(A,B)={} & int(A,B) neq {} (A,B var) --> fail 
-global_check([T1 = T2|RC],GC,[T1 = T2|NewC],F) :-   
+                                         % int-not empty: int(A,B)={} & int(A,B) neq {} (A,B var) --> fail
+global_check([T1 = T2|RC],GC,[T1 = T2|NewC],F) :-
     nonvar(T1), T1 = int(A,B), nonvar(T2), is_empty(T2), !,
     \+find_neq(int(A,B),GC),
     global_check(RC,GC,NewC,F).
 
                                          % un-rel/pfun: un(X,Y,Z) & rel(Z)/pfun(Z) --> ...
-global_check([C|RC],GC,AddedC,f) :-    
-    is_un_l(C,L,X,Y,Z), 
-    var(X), var(Y), var(Z),            
-    \+member(2,L), find_rel_pfun(Z,GC,RorF),   
+global_check([C|RC],GC,AddedC,f) :-
+    is_un_l(C,L,X,Y,Z),
+    var(X), var(Y), var(Z),
+    \+member(2,L), find_rel_pfun(Z,GC,RorF),
     !,
     trace_irules('un-pfun-dom'),
     add_dom_un(RorF,X,Y,Z,AddedC,L,NewC),
     global_check(RC,GC,NewC,f).
                                          % un-rel/pfun: un(X,Y,Z) & rel(Z)/pfun(Z) --> ...
-global_check([C|RC],GC,AddedC,f) :-    
-   is_un_l(C,L,X,Y,Z),                  
-   var(X), var(Y), var(Z),            
-   \+member(3,L), find_rel_pfun(Z,GC,RorF),    
+global_check([C|RC],GC,AddedC,f) :-
+   is_un_l(C,L,X,Y,Z),
+   var(X), var(Y), var(Z),
+   \+member(3,L), find_rel_pfun(Z,GC,RorF),
    !,
    trace_irules('un-pfun-ran'),
    add_ran_un(RorF,X,Y,Z,AddedC,L,NewC),
    global_check(RC,GC,NewC,f).
 
- 
+
 %%%%%%%%%%%%%%%%%%%%%%%%%%%% all other constraints - nothing to do
 
 global_check([C|RC],GC,[C|NewC],F) :-
@@ -3978,122 +3978,122 @@ global_check([C|RC],GC,[C|NewC],F) :-
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%% auxiliary predicates for global_check/3
 
-is_un(un(X,Y,Z),_,X,Y,Z) :- !.              
-is_un(solved(un(X,Y,Z),_,Lev,_),Lev,X,Y,Z).              
-is_un_l(un(X,Y,Z),[],X,Y,Z) :- !.                            
-is_un_l(solved(un(X,Y,Z),_,L,_),L,X,Y,Z).              
+is_un(un(X,Y,Z),_,X,Y,Z) :- !.
+is_un(solved(un(X,Y,Z),_,Lev,_),Lev,X,Y,Z).
+is_un_l(un(X,Y,Z),[],X,Y,Z) :- !.
+is_un_l(solved(un(X,Y,Z),_,L,_),L,X,Y,Z).
 
-is_size(size(X,N),_,X,N) :- !.   
-is_size(solved(size(X,N),_,Lev,_),Lev,X,N) :- !.   
-is_size(delay( (size(X,N) & true), _),_,X,N).   
-%is_size(delay( (irreducible(size(X,N)) & true), _),_,X,N) :- 
+is_size(size(X,N),_,X,N) :- !.
+is_size(solved(size(X,N),_,Lev,_),Lev,X,N) :- !.
+is_size(delay( (size(X,N) & true), _),_,X,N).
+%is_size(delay( (irreducible(size(X,N)) & true), _),_,X,N) :-
 
-is_sum(sum(X,N),_,X,N) :- !.     
-is_sum(solved(sum(X,N),_,Lev,_),Lev,X,N).     
+is_sum(sum(X,N),_,X,N) :- !.
+is_sum(solved(sum(X,N),_,Lev,_),Lev,X,N).
 
-is_min(smin(X,N),_,X,N) :- !.          
-is_min(solved(smin(X,N),_,Lev,_),Lev,X,N).     
+is_min(smin(X,N),_,X,N) :- !.
+is_min(solved(smin(X,N),_,Lev,_),Lev,X,N).
 
-is_max(smax(X,N),_,X,N) :- !.          
-is_max(solved(smax(X,N),_,Lev,_),Lev,X,N).     
+is_max(smax(X,N),_,X,N) :- !.
+is_max(solved(smax(X,N),_,Lev,_),Lev,X,N).
 
-is_neq(X neq Y,_,X,Y) :- !.            
-is_neq(solved(X neq Y,_,Lev,_),Lev,X,Y).          
+is_neq(X neq Y,_,X,Y) :- !.
+is_neq(solved(X neq Y,_,Lev,_),Lev,X,Y).
 
-is_nin(X nin Y,_,X,Y) :- !.          
-is_nin(solved(X nin Y,_,Lev,_),Lev,X,Y).          
+is_nin(X nin Y,_,X,Y) :- !.
+is_nin(solved(X nin Y,_,Lev,_),Lev,X,Y).
 
-is_dom_l(dom(X,N),[],X,N,rel) :- !.     
+is_dom_l(dom(X,N),[],X,N,rel) :- !.
 is_dom_l(solved(dom(X,N),_,L,_),L,X,N,rel) :- !.
-is_dom_l(dompf(X,N),[],X,N,pfun) :- !.     
+is_dom_l(dompf(X,N),[],X,N,pfun) :- !.
 is_dom_l(solved(dompf(X,N),_,L,_),L,X,N,pfun).
 
-is_ran_l(ran(X,N),[],X,N) :- !.         
+is_ran_l(ran(X,N),[],X,N) :- !.
 is_ran_l(solved(ran(X,N),_,L,_),L,X,N).
-    
-is_comp(comp(X,Y,Z),_,X,Y,Z) :- !.                                  
-is_comp(solved(comp(X,Y,Z),_,Lev,_),Lev,X,Y,Z) :- !.                            
-is_comp(comppf(X,Y,Z),_,X,Y,Z) :- !.                
-is_comp(solved(comppf(X,Y,Z),_,Lev,_),Lev,X,Y,Z).                            
- 
-is_rel(rel(X),_,X) :- !.     
-is_rel(solved(rel(X),_,Lev,_),Lev,X). 
-
-is_pfun(pfun(X),_,X) :- !.     
-is_pfun(solved(pfun(X),_,Lev,_),Lev,X). 
-
-has_ris(RIS = E,_,D) :- 
-      nonvar(RIS), is_ris(RIS,ris(_,D,_,_,_)),  
-      var(D), nonvar(E), is_empty(E),!.             
-has_ris(_ nin RIS,_,D) :- 
-      nonvar(RIS), is_ris(RIS,ris(_,D,_,_,_)),  
-      var(D),!.             
-has_ris2(RIS1 = RIS2,_,D1,D2) :- 
-      nonvar(RIS1), is_ris(RIS1,ris(_,D1,_,_,_)), var(D1), 
-      nonvar(RIS2), is_ris(RIS2,ris(_,D2,_,_,_)), var(D2),!.             
+
+is_comp(comp(X,Y,Z),_,X,Y,Z) :- !.
+is_comp(solved(comp(X,Y,Z),_,Lev,_),Lev,X,Y,Z) :- !.
+is_comp(comppf(X,Y,Z),_,X,Y,Z) :- !.
+is_comp(solved(comppf(X,Y,Z),_,Lev,_),Lev,X,Y,Z).
+
+is_rel(rel(X),_,X) :- !.
+is_rel(solved(rel(X),_,Lev,_),Lev,X).
+
+is_pfun(pfun(X),_,X) :- !.
+is_pfun(solved(pfun(X),_,Lev,_),Lev,X).
+
+has_ris(RIS = E,_,D) :-
+      nonvar(RIS), is_ris(RIS,ris(_,D,_,_,_)),
+      var(D), nonvar(E), is_empty(E),!.
+has_ris(_ nin RIS,_,D) :-
+      nonvar(RIS), is_ris(RIS,ris(_,D,_,_,_)),
+      var(D),!.
+has_ris2(RIS1 = RIS2,_,D1,D2) :-
+      nonvar(RIS1), is_ris(RIS1,ris(_,D1,_,_,_)), var(D1),
+      nonvar(RIS2), is_ris(RIS2,ris(_,D2,_,_,_)), var(D2),!.
 
 %%%%%% searching constraints in the entire CS
 
-find_neq(Int,cs([I neq E|_],_)) :-             
+find_neq(Int,cs([I neq E|_],_)) :-
        nonvar(E), is_empty(E), I == Int,!.
-find_neq(Int,cs([_|R],Others)) :- 
+find_neq(Int,cs([_|R],Others)) :-
        find_neq(Int,cs(R,Others)).
 
-find_setconstraint(X,cs(_,[C|_])) :-                    
+find_setconstraint(X,cs(_,[C|_])) :-
        is_un_l(C,_,S1,S2,S3),                % un(X,_Y,_Z) or un(_Y,X,_Z) or un(_Y,_Z,X) is in the CS
        var(S1), var(S2), var(S3),
        (X == S1,! ; X == S2,! ; X == S3),!.
 find_setconstraint(X,cs(Neqs,[_|R])) :-      % suppress neq elimination
        noneq_elim,!,
        find_setconstraint(X,cs(Neqs,R)).
-find_setconstraint(X,cs(_,[C|_])) :-                    
+find_setconstraint(X,cs(_,[C|_])) :-
        is_dom_l(C,_,S1,S2,_),                % dom(X,_Y) or dom(_Y,X) is in the CS
        var(S1), var(S2),
        (X == S1,! ; X == S2),!.
-find_setconstraint(X,cs(_,[C|_])) :-                    
+find_setconstraint(X,cs(_,[C|_])) :-
        is_ran_l(C,_,S1,S2),                  % ran(X,_Y) or ran(_Y,X) is in the CS
        var(S1), var(S2),
        (X == S1,! ; X == S2),!.
-find_setconstraint(X,cs(_,[C|_])) :-                    
+find_setconstraint(X,cs(_,[C|_])) :-
        is_comp(C,_,S1,S2,S3),                % comp(X,_Y,_Z) or comp(_Y,X,_Z) or comp(_Y,_Z,X) is in the CS
        var(S3),
        (X == S1,! ; X == S2,! ; X == S3),!.
-find_setconstraint(X,cs(_,[C|_])) :-                    
-       has_ris(C,_,D),                       % ris(_,D,_,_,_) = {} or T neq ris(_,D,_,_,_), D var., is in the CS 
+find_setconstraint(X,cs(_,[C|_])) :-
+       has_ris(C,_,D),                       % ris(_,D,_,_,_) = {} or T neq ris(_,D,_,_,_), D var., is in the CS
        X == D,!.
-find_setconstraint(X,cs(_,[C|_])) :-                    
-       has_ris2(C,_,D1,D2),                  % ris(_,D1,_,_,_) = ris(_,D2,_,_,_), D1, D2 var., is in the CS 
+find_setconstraint(X,cs(_,[C|_])) :-
+       has_ris2(C,_,D1,D2),                  % ris(_,D1,_,_,_) = ris(_,D2,_,_,_), D1, D2 var., is in the CS
        (X == D1,! ; X == D2),!.
-find_setconstraint(X,cs(Neqs,[_|R])) :- 
+find_setconstraint(X,cs(Neqs,[_|R])) :-
        find_setconstraint(X,cs(Neqs,R)).
 
-find_setconstraint(X,Y,cs(_,[C|_]),Z1,Z2) :-     
+find_setconstraint(X,Y,cs(_,[C|_]),Z1,Z2) :-
        is_un(C,_,S1,S2,S3),                  % un(X,Y,Z) or un(Y,X,Z) or un(Y,Z,X) is in the CS?
        var(S1), var(S2), var(S3),
        one_of3(X,Y,S1,S2,S3,Z1,Z2),!.
 find_setconstraint(X,Y,cs(Neqs,[_|R]),Z1,Z2) :-  % suppress neq elimination
        noneq_elim,!,
        find_setconstraint(X,Y,cs(Neqs,R),Z1,Z2).
-find_setconstraint(X,Y,cs(_,[C|_]),Z1,Z2) :-     
+find_setconstraint(X,Y,cs(_,[C|_]),Z1,Z2) :-
        is_dom_l(C,_,S1,S2,_),                % dom(X,Y) or dompf(Y,X) is in the CS?
        var(S1), var(S2),
        one_of2(X,Y,S1,S2,Z1,Z2),!.
-find_setconstraint(X,Y,cs(_,[C|_]),Z1,Z2) :-     
+find_setconstraint(X,Y,cs(_,[C|_]),Z1,Z2) :-
        is_ran_l(C,_,S1,S2),                  % ran(X,Y) or ran(Y,X) is in the CS?
        var(S1), var(S2),
        one_of2(X,Y,S1,S2,Z1,Z2),!.
-find_setconstraint(X,Y,cs(_,[C|_]),Z1,Z2) :-     
+find_setconstraint(X,Y,cs(_,[C|_]),Z1,Z2) :-
        is_comp(C,_,S1,S2,S3),                % comp(X,Y,Z) or comp(Y,X,Z) or comp(Y,Z,X) is in the CS?
        var(S3),
        one_of3(X,Y,S1,S2,S3,Z1,Z2),!.
-find_setconstraint(X,Y,cs(_,[C|_]),Z1,Z2) :-     
-       has_ris(C,_,D),                       % ris(_,D,_,_,_) = {} or T neq ris(_,D,_,_,_), D var., is in the CS  
+find_setconstraint(X,Y,cs(_,[C|_]),Z1,Z2) :-
+       has_ris(C,_,D),                       % ris(_,D,_,_,_) = {} or T neq ris(_,D,_,_,_), D var., is in the CS
        one_of1(X,Y,D,Z1,Z2),!.
-find_setconstraint(X,Y,cs(_,[C|_]),Z1,Z2) :-     
-       has_ris2(C,_,D1,D2),                  % ris(_,D1,_,_,_) = ris(_,D2,_,_,_), D1, D2 var., is in the CS  
+find_setconstraint(X,Y,cs(_,[C|_]),Z1,Z2) :-
+       has_ris2(C,_,D1,D2),                  % ris(_,D1,_,_,_) = ris(_,D2,_,_,_), D1, D2 var., is in the CS
        one_of2(X,Y,D1,D2,Z1,Z2),!.
 
-find_setconstraint(X,Y,cs(Neqs,[_|R]),Z1,Z2) :- 
+find_setconstraint(X,Y,cs(Neqs,[_|R]),Z1,Z2) :-
        find_setconstraint(X,Y,cs(Neqs,R),Z1,Z2).
 
 one_of3(X,Y,S1,_,_,X,Y) :- X == S1,!.
@@ -4112,7 +4112,7 @@ one_of1(X,Y,S1,X,Y) :- X == S1,!.
 one_of1(X,Y,S1,Y,X) :- Y == S1.
 
 find_nin(X,cs(_,[C|_]),T) :-        % T nin X is in the CS
-       is_nin(C,_,T,Y),     
+       is_nin(C,_,T,Y),
        X == Y,!.
 find_nin(X,cs(Neqs,[_|R]),T) :-
        find_nin(X,cs(Neqs,R),T).
@@ -4120,75 +4120,75 @@ find_nin(X,cs(Neqs,[_|R]),T) :-
 find_size2(X,Y,cs(_,[C|_]),N) :-    % size(X,N) or size(Y,N) is in the CS
        is_size(C,_,S,N),
        (X == S,! ; Y == S),!.
-find_size2(X,Y,cs(Neqs,[_|R]),M) :- 
+find_size2(X,Y,cs(Neqs,[_|R]),M) :-
        find_size2(X,Y,cs(Neqs,R),M).
 
 find_size3(X,Y,Z,cs(_,[C|_]),N) :-  % size(X,N) or size(Y,N) or size(Z,N) is in the CS
        is_size(C,_,S,N),
        (X == S,! ; Y == S,! ; Z == S),!.
-find_size3(X,Y,Z,cs(Neqs,[_|R]),M) :- 
+find_size3(X,Y,Z,cs(Neqs,[_|R]),M) :-
        find_size3(X,Y,Z,cs(Neqs,R),M).
 
-find_rel(X,cs(_,[C|_])) :-          % rel(X) is in the CS  
+find_rel(X,cs(_,[C|_])) :-          % rel(X) is in the CS
        is_rel(C,_,Y),
        X == Y,!.
-find_rel(X,cs(Neqs,[_|R])) :- 
+find_rel(X,cs(Neqs,[_|R])) :-
        find_rel(X,cs(Neqs,R)).
 
-find_pfun(X,cs(_,[C|_])) :-         % pfun(X) is in the CS  
+find_pfun(X,cs(_,[C|_])) :-         % pfun(X) is in the CS
        is_pfun(C,_,Y),
        X == Y,!.
-find_pfun(X,cs(Neqs,[_|R])) :- 
+find_pfun(X,cs(Neqs,[_|R])) :-
        find_pfun(X,cs(Neqs,R)).
 
-find_rel_pfun(X,CS,RorF) :-         % either rel(X) or pfun(X) is in the CS  
+find_rel_pfun(X,CS,RorF) :-         % either rel(X) or pfun(X) is in the CS
        (find_rel(X,CS),!, RorF=rel ; find_pfun(X,CS), RorF=pfun).
 
 %%%%%% searching constraints in the rest of the CS
 
 find_un2(X,Y,[C|_],S3) :-           % un(X,Y,_Z) or un(Y,X,_Z) is in the CS
-       is_un_l(C,_,S1,S2,S3), 
+       is_un_l(C,_,S1,S2,S3),
        (X == S1, Y == S2,! ; X == S2, Y == S1),!.
-find_un2(X,Y,[_|R],S3) :- 
+find_un2(X,Y,[_|R],S3) :-
        find_un2(X,Y,R,S3).
 
 find_size(X,[C|_],N) :-             % size(X,N) is in the CS
        is_size(C,_,S,N),
        X == S,!.
-find_size(X,[_|R],M) :- 
+find_size(X,[_|R],M) :-
        find_size(X,R,M).
 
 find_sum(X,[C|_],N) :-              % sum(X,N) is in the CS
        is_sum(C,_,S,N),
        X == S,!.
-find_sum(X,[_|R],M) :- 
+find_sum(X,[_|R],M) :-
        find_sum(X,R,M).
 
-find_min(X,[C|_],N) :-              % smin(X,N) is in the CS  
+find_min(X,[C|_],N) :-              % smin(X,N) is in the CS
        is_min(C,_,S,N),
        X == S,!.
-find_min(X,[_|R],M) :- 
+find_min(X,[_|R],M) :-
        find_min(X,R,M).
 
-find_max(X,[C|_],N) :-              % smax(X,N) is in the CS 
+find_max(X,[C|_],N) :-              % smax(X,N) is in the CS
        is_max(C,_,S,N),
        X == S,!.
-find_max(X,[_|R],M) :- 
+find_max(X,[_|R],M) :-
        find_max(X,R,M).
 
-find_dom(X,[C|_],N) :-              % dom(X,N) is in the CS  
+find_dom(X,[C|_],N) :-              % dom(X,N) is in the CS
        is_dom_l(C,_,S,N,_),
        X == S,!.
-find_dom(X,[_|R],M) :- 
+find_dom(X,[_|R],M) :-
        find_dom(X,R,M).
 
-find_ran(X,[C|_],N) :-              % ran(X,N) is in the CS  
+find_ran(X,[C|_],N) :-              % ran(X,N) is in the CS
        is_ran_l(C,_,S,N),
        X == S,!.
-find_ran(X,[_|R],M) :- 
+find_ran(X,[_|R],M) :-
        find_ran(X,R,M).
 
-%%%%%% type checking 
+%%%%%% type checking
 
 type_constr(C) :-
        (p_type_constr(C),! ; n_type_constr(C)).
@@ -4196,9 +4196,9 @@ type_constr(C) :-
 p_type_constr(set(_)).                     % positive type constraints
 p_type_constr(bag(_)).
 p_type_constr(list(_)).
-p_type_constr(integer(_)).  
-p_type_constr(rel(_)).   
-p_type_constr(pfun(_)).    
+p_type_constr(integer(_)).
+p_type_constr(rel(_)).
+p_type_constr(pfun(_)).
 
 n_type_constr(ninteger(_)).                % negative type constraints
 
@@ -4221,7 +4221,7 @@ type_err(integer(X),[ninteger(Y)|_R]):-    % integer(X) & ninteger(X): not compa
 type_err(ninteger(X),[integer(Y)|_R]):-    % ninteger(X) & integer(X): not compatible
        X == Y, !.
 type_err(C,[B|_R]):-                       % (other) different type constraints for the same variable: not compatible
-       p_type_constr(C), p_type_constr(B), 
+       p_type_constr(C), p_type_constr(B),
        C =.. [F1,X], B =.. [F2,Y],
        X == Y, F1 \== F2,!.
 type_err(A,[_|R]):-                        % compatible; check other constraints in R
@@ -4234,7 +4234,7 @@ mk_new_constr(W,T,OutC):-
 mk_new_constr(W,T,OutC):-
        T = _M with N, OutC = [N nin W,set(T)].
 mk_new_constr(W,T,OutC):-
-       W = {}, OutC = [T neq {}].  
+       W = {}, OutC = [T neq {}].
 
 mk_new_constr2(W,T,OutC):-
        nonvar(T), is_empty(T),!,
@@ -4248,20 +4248,20 @@ mk_new_constr2(W,T,OutC):-
 %%%%%% adding dom and ran for relations/partial functions
 
 add_dom_un(rel,X,Y,Z,AddedC,L,NewC) :-
-    AddedC = [solved(un(X,Y,Z),(var(X),var(Y),var(Z)),[2|L],f),   
+    AddedC = [solved(un(X,Y,Z),(var(X),var(Y),var(Z)),[2|L],f),
                         rel(X),rel(Y),dom(X,DX),dom(Y,DY),dom(Z,DZ),
                         un(DX,DY,DZ)|NewC].
 add_dom_un(pfun,X,Y,Z,AddedC,L,NewC) :-
-    AddedC = [solved(un(X,Y,Z),(var(X),var(Y),var(Z)),[2|L],f),   
+    AddedC = [solved(un(X,Y,Z),(var(X),var(Y),var(Z)),[2|L],f),
                         pfun(X),pfun(Y),dompf(X,DX),dompf(Y,DY),dompf(Z,DZ),
                         un(DX,DY,DZ)|NewC].
 
 add_ran_un(rel,X,Y,Z,AddedC,L,NewC) :-
-   AddedC = [solved(un(X,Y,Z),(var(X),var(Y),var(Z)),[3|L],f),   
+   AddedC = [solved(un(X,Y,Z),(var(X),var(Y),var(Z)),[3|L],f),
                         rel(X),rel(Y),ran(X,RX),ran(Y,RY),ran(Z,RZ),
                         un(RX,RY,RZ)|NewC].
 add_ran_un(pfun,X,Y,Z,AddedC,L,NewC) :-
-   AddedC = [solved(un(X,Y,Z),(var(X),var(Y),var(Z)),[3|L],f),   
+   AddedC = [solved(un(X,Y,Z),(var(X),var(Y),var(Z)),[3|L],f),
                         pfun(X),pfun(Y),ran(X,RX),ran(Y,RY),ran(Z,RZ),
                         un(RX,RY,RZ)|NewC].
 
@@ -4277,69 +4277,69 @@ add_dom_neqd(pfun,S,D,AddedC,L,NewC) :-
 
 add_ran_size(S,R,M,N,AddedC,L,NewC) :-
     noran_elim,!,
-    AddedC = [solved(ran(S,R),(var(S),var(R);var(S),nonvar(R),\+(is_empty(R))),[2|L],f),   
+    AddedC = [solved(ran(S,R),(var(S),var(R);var(S),nonvar(R),\+(is_empty(R))),[2|L],f),
                size(S,N),size(R,M),integer(N),integer(M)|NewC].
 add_ran_size(S,R,M,N,AddedC,L,NewC) :-
-    AddedC = [solved(ran(S,R),(var(S),var(R)),[2|L],f),   
+    AddedC = [solved(ran(S,R),(var(S),var(R)),[2|L],f),
                size(S,N),size(R,M),integer(N),integer(M)|NewC].
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%           Level 3           %%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%  Labeling and final check   %%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- 
-final_sat(C,SFC):- 
+
+final_sat(C,SFC):-
       trace_in(C,3),
-      final_sat1(C,SFC0), 
+      final_sat1(C,SFC0),
       final_sat2(SFC0,SFC),
-      trace_out(SFC,3).  
+      trace_out(SFC,3).
 
 final_sat1([],[]) :-!.
-final_sat1(C,SFC):- 
-      sat_empty_intv(C,CC),   
-      check_domain(CC),                  %force labeling for integer variables;  
-      sat(CC,RevC,f),                    %call the constraint solver (in 'final' mode); 
+final_sat1(C,SFC):-
+      sat_empty_intv(C,CC),
+      check_domain(CC),                  %force labeling for integer variables;
+      sat(CC,RevC,f),                    %call the constraint solver (in 'final' mode);
       final_sat_cont(RevC,CC,SFC).
 
 final_sat_cont(RevC,C,RevC) :-
       RevC == C,!.
-final_sat_cont(RevC,_C,SFC) :-           %RevC is the resulting constraint; 
+final_sat_cont(RevC,_C,SFC) :-           %RevC is the resulting constraint;
       final_sat1(RevC,SFC).              %otherwise, call 'final_sat' again
- 
+
 final_sat2([],[]) :-!.
-final_sat2(C,SFC):- 
+final_sat2(C,SFC):-
       check_domain(C),                   %force labeling for integer variables;
-      set_final, 
-      sat(C,RevC,f),                     %call the constraint solver (in 'final' mode); 
+      set_final,
+      sat(C,RevC,f),                     %call the constraint solver (in 'final' mode);
       final_sat_cont2(RevC,C,SFC).
 
 final_sat_cont2(RevC,C,RevC) :-
       RevC == C,!,
       retract_final.
-final_sat_cont2(RevC,_C,SFC) :-          %RevC is the resulting constraint; 
+final_sat_cont2(RevC,_C,SFC) :-          %RevC is the resulting constraint;
       final_sat2(RevC,SFC).              %otherwise, call 'final_sat' again
- 
-check_domain(C):-                        %to force labeling (if possible) for integer         
-      memberrest(integer(X),C,CRest),!,  %variables that are still uninstantiated in 
-      labeling(X),                       %the constraint C 
+
+check_domain(C):-                        %to force labeling (if possible) for integer
+      memberrest(integer(X),C,CRest),!,  %variables that are still uninstantiated in
+      labeling(X),                       %the constraint C
       check_domain(CRest).
 check_domain(_).
-                      
-sat_empty_intv([],[]) :- !.              
-sat_empty_intv([T1 = T2|R1],[integer(A),integer(B)|R2]) :- 
+
+sat_empty_intv([],[]) :- !.
+sat_empty_intv([T1 = T2|R1],[integer(A),integer(B)|R2]) :-
       nonvar(T1), T1 = int(A,B), nonvar(T2), is_empty(T2),!,
       solve_FD(A > B),
       sat_empty_intv(R1,R2).
-sat_empty_intv([T1 neq T2|R1],[integer(A),integer(B)|R2]) :- 
+sat_empty_intv([T1 neq T2|R1],[integer(A),integer(B)|R2]) :-
       nonvar(T1), T1 = int(A,B), nonvar(T2), is_empty(T2),!,
       solve_FD(A =< B),
       sat_empty_intv(R1,R2).
-sat_empty_intv([C|R1],[C|R2]) :- 
+sat_empty_intv([C|R1],[C|R2]) :-
       sat_empty_intv(R1,R2).
 
-set_final :-             
+set_final :-
         final,!.
-set_final :-    
+set_final :-
         assert(final).
 
 retract_final :-
@@ -4348,7 +4348,7 @@ retract_final.
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%     FD constraints 
+%%%%%%%%%%%%%%%%     FD constraints
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 solve_FD(Constr) :-             % Solve the constraint 'Constr' using the FD solver
@@ -4357,27 +4357,27 @@ solve_FD(Constr) :-             % Solve the constraint 'Constr' using the FD sol
 
 fd_eq(X,E) :-
        X #= E.
-       
+
 tau(X is E,X #= E).             % The translation function: from SET constraints to FD
 tau(X =< Y,X #=< Y).            % constraints, and vice versa
-tau(X >= Y,X #>= Y).             
-tau(X < Y,X #< Y).              
-tau(X > Y,X #> Y).              
+tau(X >= Y,X #>= Y).
+tau(X < Y,X #< Y).
+tau(X > Y,X #> Y).
 tau(X neq T,X #\= T).
 tau(T in int(A,B),T in A..B) :- !.
 tau(T in D,T in D).
 
-labeling(_) :-                     % if nolabel, do nothing        
-       nolabel,!.                     
-labeling(X) :-                     % if the variable X has a closed domain associated 
-       get_domain(X,X in D),!,     % with it, then X is (non-deterministically) instantiated 
-       labeling1(X,D).             % to every value belonging to the domain.             
+labeling(_) :-                     % if nolabel, do nothing
+       nolabel,!.
+labeling(X) :-                     % if the variable X has a closed domain associated
+       get_domain(X,X in D),!,     % with it, then X is (non-deterministically) instantiated
+       labeling1(X,D).             % to every value belonging to the domain.
 labeling(_).                       % Otherwise, the predicate is true and X remains unchanghed
 
 is_fd_var(X) :-
        clpfd:fd_var(X).
 
-get_domain(X,(X in D)) :-          % get_domain(X,FDc): true if X is a variable and 
+get_domain(X,(X in D)) :-          % get_domain(X,FDc): true if X is a variable and
        var(X),                     % FDc is the interval membership constraint for X
        clpfd:fd_dom(X,D).
 
@@ -4404,33 +4404,33 @@ labeling1(X,(I) \/ (In)) :-        % e.g., X in (inf..2)\/(4..5)\/(7..9)
         ;
         X in (inf..B)).
 labeling1(X,_D) :-                 % e.g., X in (1..2)\/(4..5)\/(7..9)
-        clpfd:indomain(X).  
+        clpfd:indomain(X).
 %DBG%   clpfd:labeling([ff,down,enum],[X]).
 
 
-first_int((A .. B),(A .. B),(1 .. 0)) :- !.      % first_int(+Int,?Rest,?First) 
+first_int((A .. B),(A .. B),(1 .. 0)) :- !.      % first_int(+Int,?Rest,?First)
 first_int((I) \/ (In),I0,(IRest) \/ (In)) :-     % 'Int' is a disj. of intervals and
        first_int(I,I0,IRest).                    % 'First' is the first disjunct
                                                  % 'Rest' the remaining part
 
 %%%%%%%%%%%%%%
 
-%add_FDc(SETc,SETFDc,R)       
+%add_FDc(SETc,SETFDc,R)
 %SETFDc is the list of contraints obtained by appending the list FDc
 %of interval constraints still occurring in the FD constraint store
-%to the list of constraints SETc. R is either 'y' if at least one 
+%to the list of constraints SETc. R is either 'y' if at least one
 %such interval constraints is found; otherwise, R is uninitialized
 
-add_FDc([],[],_) :- !.                                          
-add_FDc([C|SETc],[C|FDc],Warning) :-  
+add_FDc([],[],_) :- !.
+add_FDc([C|SETc],[C|FDc],Warning) :-
        \+(C = integer(_)),!,
-       add_FDc(SETc,FDc,Warning).                                           
-add_FDc([integer(X)|SETc],[integer(X)|FDc],Warning) :-  
+       add_FDc(SETc,FDc,Warning).
+add_FDc([integer(X)|SETc],[integer(X)|FDc],Warning) :-
        \+is_fd_var(X),!,
-       add_FDc(SETc,FDc,Warning).  
-add_FDc([integer(X)|SETc],FDc,Warning) :-  
+       add_FDc(SETc,FDc,Warning).
+add_FDc([integer(X)|SETc],FDc,Warning) :-
        get_domain(X,FD),
-       tau(X in D,FD), 
+       tau(X in D,FD),
        (nolabel,! ; Warning = y),
        (D == int(inf,sup),!,FDc = [integer(X)|FDcCont]
         ;
@@ -4440,35 +4440,35 @@ add_FDc([integer(X)|SETc],FDc,Warning) :-
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%     Program defined constraints 
+%%%%%%%%%%%%%%%%     Program defined constraints
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 isetlog((true :- true),sys).
-isetlog((less(A,X,C) :- 
+isetlog((less(A,X,C) :-
          A = C with X & set(C) & X nin C & true),sys).
-isetlog((nsubset(A,B) :- 
+isetlog((nsubset(A,B) :-
          set(A) & set(B) & X in A & X nin B & true),sys).
-isetlog((ninters(A,B,C) :- 
+isetlog((ninters(A,B,C) :-
          set(A) & set(B) & set(C) & X in C &
          (X nin A & true or X nin B & true) & true),sys).
-isetlog((diff(A,B,C) :- 
+isetlog((diff(A,B,C) :-
          set(A) & set(B) & set(C) &
          subset(C,A) & un(B,C,D) & subset(A,D) & disj(B,C) & true),sys).
-isetlog((ndiff(A,B,C) :- 
+isetlog((ndiff(A,B,C) :-
          set(A) & set(B) & set(C) &
          diff(A,B,D) & D neq C & true),sys).
-isetlog((sdiff(A,B,C) :- 
+isetlog((sdiff(A,B,C) :-
          set(A) & set(B) & set(C) &
          diff(A,B,D) & diff(B,A,E) & un(D,E,C) & true),sys).
 
-isetlog((A =:= B :- 
+isetlog((A =:= B :-
          X is A & Y is B & X = Y & true),sys).
-isetlog((A =\= B :- 
+isetlog((A =\= B :-
          X is A & Y is B & X neq Y & true),sys).
 
-isetlog((rimg(B,R,S) :-   
+isetlog((rimg(B,R,S) :-
          set(B) & set(S) & rel(R) & dres(B,R,RB) & ran(RB,S) & true),sys).
-isetlog((oplus(R,S,T) :-  
+isetlog((oplus(R,S,T) :-
          rel(R) & rel(S) & rel(T) & un(RS,S,T) & ndres(DS,R,RS) & dom(S,DS) & true),sys).
 isetlog((id(A,R) :-        % for partial functions only
          set(A) & pfun(R) & dompf(R,A) & ran(R,A) & comp(R,R,R) & true),sys).
@@ -4478,9 +4478,9 @@ isetlog((id(A,R) :-        % for partial functions only
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%               
-%%%%%%%%%%%%%%     Pre / post-processor     %%%%%%%%%%%%%%%%%               
-%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%               
+%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%     Pre / post-processor     %%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -4494,39 +4494,39 @@ isetlog((id(A,R) :-        % for partial functions only
 %             transform_goal/2,
 %             transform_clause/2,
 %             is_ker/1,
-%             is_sf/3 
+%             is_sf/3
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%     Preprocessing 
+%%%%%%%%%%%%%%%%     Preprocessing
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-%%%%%%%%%%%%% Set (multiset) preprocessor: 
-%%%%%%%%%%%%% from {...} (*({...})) to 'with' ('mwith') notation  
+%%%%%%%%%%%%% Set (multiset) preprocessor:
+%%%%%%%%%%%%% from {...} (*({...})) to 'with' ('mwith') notation
 
 preproc_goal(G,PGext) :-
-        preproc(G,PG,TypeCL), 
-        norep_in_list(TypeCL,TypeCLRid),   
+        preproc(G,PG,TypeCL),
+        norep_in_list(TypeCL,TypeCLRid),
         list_to_conj(TypeCC,TypeCLRid),
         conj_append(PG,TypeCC,PGext).
 
 preproc_clause(Cl,(PA :- PBext)) :-
-        preproc(Cl,(PA :- PB),TypeCL), 
-        norep_in_list(TypeCL,TypeCLRid),   
+        preproc(Cl,(PA :- PB),TypeCL),
+        norep_in_list(TypeCL,TypeCLRid),
         list_to_conj(TypeCC,TypeCLRid),
         conj_append(PB,TypeCC,PBext).
 
-preproc(X,X,[]):- 
-        var(X),!.      
+preproc(X,X,[]):-
+        var(X),!.
 preproc(X,X,[]):-
         atomic(X),!.
 preproc(X,Y1,C):-
         is_set_ext(X), !,
         set_preproc(X,Y,C),
-        norep_in_set(Y,Y1). 
+        norep_in_set(Y,Y1).
 preproc(X,Y,C):-
         is_bag_ext(X),!,
         bag_preproc(X,Y,C).
-preproc([A|X],[A1|X],[type(list(X))|C]):- 
+preproc([A|X],[A1|X],[type(list(X))|C]):-
         var(X), !,
         preproc(A,A1,C).
 preproc((A & B),(A1 & B1),C):-
@@ -4536,25 +4536,25 @@ preproc((A :- B ),(A1 :- B1 ),C) :-
         !, preproc(A,A1,C1), preproc(B,B1,C2),
         append(C1,C2,C).
 
-preproc(prolog_call(G),prolog_call(G),[]) :- !.    
-preproc(naf A,naf(A1),[]) :-     
+preproc(prolog_call(G),prolog_call(G),[]) :- !.
+preproc(naf A,naf(A1),[]) :-
         !, preproc_goal(A,A1).
-preproc(call(A),call(A1),[]) :-     
+preproc(call(A),call(A1),[]) :-
         !, preproc_goal(A,A1).
-preproc(call(A,C),call(A1,C),[]) :-    
+preproc(call(A,C),call(A1,C),[]) :-
         !, preproc_goal(A,A1).
-preproc(solve(A),solve(A1),[]) :-    
+preproc(solve(A),solve(A1),[]) :-
         !, preproc_goal(A,A1).
-preproc((A)!,(A1)!,[]) :-        
+preproc((A)!,(A1)!,[]) :-
         !, preproc_goal(A,A1).
-preproc(delay(A,G),delay(A1,G),[]) :-    
+preproc(delay(A,G),delay(A1,G),[]) :-
         !, preproc_goal(A,A1).
-preproc(neg A,neg(A1),[]) :-    
+preproc(neg A,neg(A1),[]) :-
         !, preproc_goal(A,A1).
 
 preproc(X,Z,C):-
-        nonvar(X), 
-        functor(X,F,_A), 
+        nonvar(X),
+        functor(X,F,_A),
         =..(X,[F|ListX]),
         preproc_all(ListX,ListZ,C1),
         =..(Z,[F|ListZ]),
@@ -4574,15 +4574,15 @@ preproc_all([A|L1],[B|L2],C):-
 
 set_preproc({},{},[]):- !.
 set_preproc(X with A,X with B,[type(set(X))|Constrs]) :-
-        var(X),!, preproc(A,B,Constrs).       
+        var(X),!, preproc(A,B,Constrs).
 set_preproc(X with A,Y with B,Constrs) :-
         is_set_ext(X),!,
         preproc(A,B,Constrs1), preproc(X,Y,Constrs2),
-        append(Constrs1,Constrs2,Constrs). 
+        append(Constrs1,Constrs2,Constrs).
 set_preproc({}(A),B,Constrs):-
         set_preproc_elems(A,B,Constrs),!.
 set_preproc(_,_,_):-
-        msg_sort_error(set), 
+        msg_sort_error(set),
         fail.
 
 set_preproc_elems(A,{} with A,[]):-
@@ -4591,36 +4591,36 @@ set_preproc_elems((A1,B1),B2 with A2,Constrs):- !,
         preproc(A1,A2,Constrs1),
         set_preproc_elems(B1,B2,Constrs2),
         append(Constrs1,Constrs2,Constrs).
-set_preproc_elems(S,WT,Constrs):- 
+set_preproc_elems(S,WT,Constrs):-
         aggr_comps_ext(S,_A,_X),!,
-        set_preproc_set(S,WT,Constrs). 
+        set_preproc_set(S,WT,Constrs).
 set_preproc_elems(A1,{} with A2,Constrs):-
         preproc(A1,A2,Constrs).
 
-set_preproc_set(S,X with B,[type(set(X))|Constrs]):-  
-        aggr_comps_ext(S,A,X), 
-        var(X),!, 
+set_preproc_set(S,X with B,[type(set(X))|Constrs]):-
+        aggr_comps_ext(S,A,X),
+        var(X),!,
         preproc(A,B,Constrs).
-set_preproc_set(S,Y with B,Constrs):-   
-        aggr_comps_ext(S,A,X), 
+set_preproc_set(S,Y with B,Constrs):-
+        aggr_comps_ext(S,A,X),
         is_set_ext(X),!,
         preproc(A,B,Constrs1), preproc(X,Y,Constrs2),
         append(Constrs1,Constrs2,Constrs).
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% bag preprocessing
 
-bag_preproc({},{},[]):-!.   
+bag_preproc({},{},[]):-!.
 bag_preproc(X mwith A,X mwith B,[type(bag(X))|Constrs]) :-
-        var(X),!, preproc(A,B,Constrs).       
+        var(X),!, preproc(A,B,Constrs).
 bag_preproc(X mwith A,Y with B,Constrs) :-
         is_bag_ext(X),!,
         preproc(A,B,Constrs1), preproc(X,Y,Constrs2),
-        append(Constrs1,Constrs2,Constrs). 
-bag_preproc((*({}(A))),B,Constrs):- 
+        append(Constrs1,Constrs2,Constrs).
+bag_preproc((*({}(A))),B,Constrs):-
         bag_preproc_elems(A,B,Constrs),!.
 bag_preproc(_,_,_):-
-        msg_sort_error(bag), 
-        fail. 
+        msg_sort_error(bag),
+        fail.
 
 bag_preproc_elems(A, {} mwith A,[]):-
         var(A),!.
@@ -4628,16 +4628,16 @@ bag_preproc_elems((A1,B1),B2 mwith A2,Constrs):-
         !,preproc(A1,A2,Constrs1),
         bag_preproc_elems(B1,B2,Constrs2),
         append(Constrs1,Constrs2,Constrs).
-bag_preproc_elems(M,MWT,Constrs):-         
+bag_preproc_elems(M,MWT,Constrs):-
         aggr_comps_ext(M,_A,_X),!,
-        bag_preproc_bag(M,MWT,Constrs).    
+        bag_preproc_bag(M,MWT,Constrs).
 bag_preproc_elems(A1,{} mwith A2,Constrs):-
         preproc(A1,A2,Constrs).
 
-bag_preproc_bag(M,X mwith B,[type(bag(X))|Constrs]):-       
+bag_preproc_bag(M,X mwith B,[type(bag(X))|Constrs]):-
         aggr_comps_ext(M,A,X), var(X),!,
         preproc(A,B,Constrs).
-bag_preproc_bag(M,Y mwith B,Constrs):-!,    
+bag_preproc_bag(M,Y mwith B,Constrs):-!,
         aggr_comps_ext(M,A,X), is_bag_ext(X),!,
         preproc(A,B,Constrs1), preproc(X,Y,Constrs2),
         append(Constrs1,Constrs2,Constrs).
@@ -4646,31 +4646,31 @@ bag_preproc_bag(M,Y mwith B,Constrs):-!,
 
 gen_type_constrs(un(T1,T2,T3),[type(set(T1)),type(set(T2)),type(set(T3))]) :- !.
 gen_type_constrs(nun(T1,T2,T3),[type(set(T1)),type(set(T2)),type(set(T3))]) :- !.
-gen_type_constrs(disj(T1,T2),[type(set(T1)),type(set(T2))]) :- !.  
+gen_type_constrs(disj(T1,T2),[type(set(T1)),type(set(T2))]) :- !.
 gen_type_constrs(ndisj(T1,T2),[type(set(T1)),type(set(T2))]) :- !.
 gen_type_constrs(subset(T1,T2),[type(set(T1)),type(set(T2))]) :- !.
 gen_type_constrs(ssubset(T1,T2),[type(set(T1)),type(set(T2))]) :- !.
 gen_type_constrs(inters(T1,T2,T3),[type(set(T1)),type(set(T2)),type(set(T3))]) :- !.
-gen_type_constrs(size(T1,T2),[type(set(T1)),type(integer(T2))]) :- !.   
+gen_type_constrs(size(T1,T2),[type(set(T1)),type(integer(T2))]) :- !.
 gen_type_constrs(sum(T1,T2),[type(set(T1)),type(integer(T2))]) :- !.
-gen_type_constrs(smin(T1,T2),[type(set(T1)),type(integer(T2))]) :- !.  
-gen_type_constrs(smax(T1,T2),[type(set(T1)),type(integer(T2))]) :- !. 
-
-gen_type_constrs(dom(T1,T2),[type(rel(T1)),type(set(T2))]) :- !.   
-gen_type_constrs(inv(T1,T2),[type(rel(T1)),type(set(T2))]) :- !.   
-gen_type_constrs(ran(T1,T2),[type(rel(T1)),type(set(T2))]) :- !.   
-gen_type_constrs(comp(T1,T2,T3),[type(rel(T1)),type(rel(T2)),type(rel(T3))]) :- !. 
-gen_type_constrs(dompf(T1,T2),[type(pfun(T1)),type(set(T2))]) :- !. 
-gen_type_constrs(comppf(T1,T2,T3),[type(rel(T1)),type(pfun(T2)),type(rel(T3))]) :- !. 
-gen_type_constrs(dres(T1,T2,T3),[type(set(T1)),type(rel(T2)),type(rel(T3))]) :- !. 
-gen_type_constrs(drespf(T1,T2,T3),[type(set(T1)),type(rel(T2)),type(rel(T3))]) :- !. 
-gen_type_constrs(rres(T1,T2,T3),[type(set(T1)),type(rel(T2)),type(rel(T3))]) :- !. 
-gen_type_constrs(ndres(T1,T2,T3),[type(set(T1)),type(rel(T2)),type(rel(T3))]) :- !. 
-gen_type_constrs(nrres(T1,T2,T3),[type(set(T1)),type(rel(T2)),type(rel(T3))]) :- !. 
+gen_type_constrs(smin(T1,T2),[type(set(T1)),type(integer(T2))]) :- !.
+gen_type_constrs(smax(T1,T2),[type(set(T1)),type(integer(T2))]) :- !.
+
+gen_type_constrs(dom(T1,T2),[type(rel(T1)),type(set(T2))]) :- !.
+gen_type_constrs(inv(T1,T2),[type(rel(T1)),type(set(T2))]) :- !.
+gen_type_constrs(ran(T1,T2),[type(rel(T1)),type(set(T2))]) :- !.
+gen_type_constrs(comp(T1,T2,T3),[type(rel(T1)),type(rel(T2)),type(rel(T3))]) :- !.
+gen_type_constrs(dompf(T1,T2),[type(pfun(T1)),type(set(T2))]) :- !.
+gen_type_constrs(comppf(T1,T2,T3),[type(rel(T1)),type(pfun(T2)),type(rel(T3))]) :- !.
+gen_type_constrs(dres(T1,T2,T3),[type(set(T1)),type(rel(T2)),type(rel(T3))]) :- !.
+gen_type_constrs(drespf(T1,T2,T3),[type(set(T1)),type(rel(T2)),type(rel(T3))]) :- !.
+gen_type_constrs(rres(T1,T2,T3),[type(set(T1)),type(rel(T2)),type(rel(T3))]) :- !.
+gen_type_constrs(ndres(T1,T2,T3),[type(set(T1)),type(rel(T2)),type(rel(T3))]) :- !.
+gen_type_constrs(nrres(T1,T2,T3),[type(set(T1)),type(rel(T2)),type(rel(T3))]) :- !.
 
 gen_type_constrs(apply(F,_,_),[type(pfun(F))]) :-        % for partial functions only
       var(F),!.
-gen_type_constrs(apply(F,_,_),[type(pfun(F))]) :-        
+gen_type_constrs(apply(F,_,_),[type(pfun(F))]) :-
       nonvar(F), F \== this.
 
 %%%%%%%%%%%%% Auxiliary predicates for set/multiset preprocessing
@@ -4682,50 +4682,50 @@ is_bag_ext({}):-!.
 is_bag_ext(X):- X = *A, functor(A,{},_), !.
 is_bag_ext(_ mwith _).
 
-aggr_comps_ext((A \ R),A,R) :-!. 
+aggr_comps_ext((A \ R),A,R) :-!.
 aggr_comps_ext((A / R),A,R).          %for compatibility with previous releases
 
 is_ker(T) :-
         nonvar(T), functor(T,F,N),
         (F \== with,! ; N \== 2).
 
-msg_sort_error(set) :- 
+msg_sort_error(set) :-
        write(' wrong set term '), nl.
-msg_sort_error(bag) :- 
+msg_sort_error(bag) :-
        write(' wrong multiset term '), nl.
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%   Intensional set preprocessing        
+%%%%%%%%%%%   Intensional set preprocessing
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-                            
+
 sf_in_clause((H :- B),(H1 :- B1)):-
     !,sf_in_literal(H,[H1|List1]),
     sf_in_goal(B,List2),
     append(List1,List2,List),
-    list_to_conj(B1,List).      
+    list_to_conj(B1,List).
 sf_in_clause(A,(H :- B)):-
     sf_in_hliteral(A,[H|List]),
     list_to_conj(B,List).
 
 sf_in_goal(A,[A]):-
-    var(A),!.    
-sf_in_goal(true,[]):-!.                   
-sf_in_goal(A & B,NewL):-    
+    var(A),!.
+sf_in_goal(true,[]):-!.
+sf_in_goal(A & B,NewL):-
     !, sf_in_literal(A,A1),
     sf_in_goal(B,B1),
     append(A1,B1,NewL).
 sf_in_goal(A,NewL):-
-    !, sf_in_literal(A,NewL).    
+    !, sf_in_literal(A,NewL).
 
-sf_in_literal(A,[A]):-                    
+sf_in_literal(A,[A]):-
     var(A),!.
 sf_in_literal(A or B,[A1 or B1]):-
     !, sf_in_goal(A,L1),
     sf_in_goal(B,L2),
     list_to_conj(A1,L1),
     list_to_conj(B1,L2).
-sf_in_literal(prolog_call(A),[prolog_call(A)]):-!. 
+sf_in_literal(prolog_call(A),[prolog_call(A)]):-!.
 sf_in_literal(neg A,[neg A1]):-
     !, sf_in_goal(A,L1),
     list_to_conj(A1,L1).
@@ -4735,7 +4735,7 @@ sf_in_literal(naf A,[naf A1]):-
 sf_in_literal(call(A),[call(A1)]):-
     !, sf_in_goal(A,L1),
     list_to_conj(A1,L1).
-sf_in_literal(call(A,C),[call(A1,C)]):-   
+sf_in_literal(call(A,C),[call(A1,C)]):-
     !, sf_in_goal(A,L1),
     list_to_conj(A1,L1).
 sf_in_literal(solve(A),[solve(A1)]):-
@@ -4761,17 +4761,17 @@ sf_in_literal(forall(X in S,A),L):-
     sf_in_goal(A,L2),
     list_to_conj(A1,L2),
     append(L1,[forall(X in S1,A1)],L).
-sf_in_literal(A,NewA):-   
+sf_in_literal(A,NewA):-
     A =.. [Pname|Args],
     sf_find(Args,Args1,NewL),
     B =.. [Pname|Args1],
     append(NewL,[B],NewA).
-        
-sf_in_hliteral(A,[B|NewL]):-                                      
+
+sf_in_hliteral(A,[B|NewL]):-
     A =.. [Pname|Args],
     sf_find(Args,Args1,NewL),
     B =.. [Pname|Args1].
-        
+
 sf_find([],[],[]).
 sf_find([Int|R],[Var|S],List):-
     is_sf(Int,X,G),!,
@@ -4780,7 +4780,7 @@ sf_find([Int|R],[Var|S],List):-
     check_control_var1(Vars,Finalvars),
     sf_translate(Int,Var,L1,Finalvars),
     sf_find(R,S,L2),
-    append(L1,L2,List).    
+    append(L1,L2,List).
 sf_find([A|R],[B|S],List):-
     nonvar(A),
     A =.. [Fname|Rest],
@@ -4795,39 +4795,39 @@ sf_find([A|R],[A|S],List):-
 check_control_var1(Vars,Finalvars) :-
     Vars == Finalvars, !,
     write('ERROR - Formula of a set former must'),
-    write(' contain the set former control variable'), nl, 
+    write(' contain the set former control variable'), nl,
     fail.
 check_control_var1(_Vars,_Finalvars).
 
 sf_translate(SF,Y,[Pred],Vars):-
     (SF={X:exists(_Var,Goal)},! ; SF={X : Goal}),
-    length([_|Vars],N),    
+    length([_|Vars],N),
     newpred(Aux,N,[115, 101, 116, 108, 111, 103, 83, 70, 95]),    % "setlogSF_"
     Aux=..[AuxName,Y|Vars],
-    newpred(Aux1,N,[115, 101, 116, 108, 111, 103, 83, 70, 95]),   
+    newpred(Aux1,N,[115, 101, 116, 108, 111, 103, 83, 70, 95]),
     Aux1 =.. [Aux1Name,X|Vars],
     Pred = sf_call(Y,Aux1Name,AuxName,Vars),
     setassert((Aux1 :- Goal)),
-    setassert((Aux :- X nin Y & Aux1)). 
-        
+    setassert((Aux :- X nin Y & Aux1)).
+
 is_sf(Int,X,Phi) :-
-    nonvar(Int), Int = {SExpr}, 
+    nonvar(Int), Int = {SExpr},
     nonvar(SExpr), SExpr = (X : Phi),
     check_control_var2(X).
 
 check_control_var2(X) :-
     nonvar(X), !,
     write('ERROR - Control variable in a set former'),
-    write(' must be a variable term!'), nl,  
+    write(' must be a variable term!'), nl,
     fail.
 check_control_var2(_X).
-              
+
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%    R.U.Q. preprocessing  %%%%%%%%%%%           
+%%%%%%%%%%%%    R.U.Q. preprocessing  %%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-                      
-ruq_in_clause((H :- B),(H :- NewB)) :-    
+
+ruq_in_clause((H :- B),(H :- NewB)) :-
     ruq_in_goal(B,NewB,B,no),!.
 ruq_in_clause(H,H).
 
@@ -4837,60 +4837,60 @@ ruq_in_goal(Goal,NewGoal) :-
 
 rewrite_goal(G,NewG) :-
     filter_on,!,
-    normalize(G,G1),           
-    ruq_in_goal(G1,G2,G1,infer_rules),    
-    ruq_in_goal(G2,NewG,G2,fail_rules).    
+    normalize(G,G1),
+    ruq_in_goal(G1,G2,G1,infer_rules),
+    ruq_in_goal(G2,NewG,G2,fail_rules).
 rewrite_goal(G,NewG) :-
-    ruq_in_goal(G,NewG,G,no).    
+    ruq_in_goal(G,NewG,G,no).
 
 ruq_in_goal(A,A,_,_):-
-    var(A),!.    
+    var(A),!.
 ruq_in_goal(A & B,GExt,G,RR):-
     !, ruq_in_goal(A,A1,G,RR), ruq_in_goal(B,B1,G,RR),
-    conj_append(A1,B1,GExt).    
+    conj_append(A1,B1,GExt).
 ruq_in_goal((A or B),((A1) or (B1)),_,RR):-
-    !, ruq_in_goal(A,A1,A,RR), ruq_in_goal(B,B1,B,RR). 
+    !, ruq_in_goal(A,A1,A,RR), ruq_in_goal(B,B1,B,RR).
 
-ruq_in_goal(prolog_call(A),prolog_call(A),_,_):-!. 
+ruq_in_goal(prolog_call(A),prolog_call(A),_,_):-!.
 ruq_in_goal(neg A,neg(A1),_,RR):-
-    !, ruq_in_goal(A,A1,A,RR).    
+    !, ruq_in_goal(A,A1,A,RR).
 ruq_in_goal(naf A,naf(A1),_,RR):-
-    !, ruq_in_goal(A,A1,A,RR).    
+    !, ruq_in_goal(A,A1,A,RR).
 ruq_in_goal(call(A),call(A1),_,no):-
     !, rewrite_goal(A,A1).
 ruq_in_goal(call(A),call(A1),_,RR):-
     !, ruq_in_goal(A,A1,A,RR).
-ruq_in_goal(call(A,C),call(A1,C),_,RR):-    
-    !, ruq_in_goal(A,A1,A,RR).   
+ruq_in_goal(call(A,C),call(A1,C),_,RR):-
+    !, ruq_in_goal(A,A1,A,RR).
 ruq_in_goal(solve(A),solve(A1),_,RR):-
-    !, ruq_in_goal(A,A1,A,RR).    
+    !, ruq_in_goal(A,A1,A,RR).
 ruq_in_goal((A)!,(A1)!,_,RR):-
-    !, ruq_in_goal(A,A1,A,RR).    
+    !, ruq_in_goal(A,A1,A,RR).
 ruq_in_goal(delay(A,G),delay(A1,G1),_,RR):-
     !, ruq_in_goal(A,A1,A,RR),
-    ruq_in_goal(G,G1,G,RR).   
- 
-ruq_in_goal(forall(X in _S,_Y),_,_,_):- 
-    nonvar(X), !, 
-    write('ERROR - Control variable in a R.U.Q. must be a variable term!'), nl, 
+    ruq_in_goal(G,G1,G,RR).
+
+ruq_in_goal(forall(X in _S,_Y),_,_,_):-
+    nonvar(X), !,
+    write('ERROR - Control variable in a R.U.Q. must be a variable term!'), nl,
     fail.
 ruq_in_goal(forall(X in S,G),NewG,_,_):-
     !, extract_vars(G,V),
     remove_var(X,V,Vars),
-    check_control_var_RUQ(V,Vars), 
+    check_control_var_RUQ(V,Vars),
     length(V,N),
     newpred(Gpred,N,[115, 101, 116, 108, 111, 103, 82, 85, 81, 95]),       %"setlogRUQ_"
     Gpred =.. [_,X|Vars],
     tmp_switch_ctxt(OldCtxt),
-    ( G = exists(_Var,B),!, 
-      setassert((Gpred :- B))     
+    ( G = exists(_Var,B),!,
+      setassert((Gpred :- B))
      ;
-      setassert((Gpred :- G)) ),  
+      setassert((Gpred :- G)) ),
     switch_ctxt(OldCtxt,_),
     functor(Gpred,F,N),
     NewG = ruq_call(S,F,Vars).
 
-ruq_in_goal(true,true,_,_) :- !. 
+ruq_in_goal(true,true,_,_) :- !.
 ruq_in_goal(A,NewG,G,RR) :-      % try to call filtering rules
     RR \== no,
     user_def_rules(A,NewG,G,RR),!.
@@ -4901,46 +4901,46 @@ ruq_in_goal(A,A,_,_).
 check_control_var_RUQ(Vars,Finalvars) :-
     Vars == Finalvars, !,
     write('ERROR - Formula of a R.U.Q. must'),
-    write(' contain the R.U.Q. control variable'), nl, 
+    write(' contain the R.U.Q. control variable'), nl,
     fail.
 check_control_var_RUQ(_Vars,_Finalvars).
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%% User-defined rewriting rules %%%%%%%%%% 
+%%%%%%%%% User-defined rewriting rules %%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-load_rwrules_lib :-                           
+load_rwrules_lib :-
     rw_rules(Lib),
     mk_file_name(Lib,FullName),
-    (exists_file(FullName),!,consult(FullName) 
-     ; 
+    (exists_file(FullName),!,consult(FullName)
+     ;
      true).
 
-normalize(Goal,NewGoal) :-   
-    ruq_in_goal(Goal,NewGoal1,Goal,replace_rules),    
+normalize(Goal,NewGoal) :-
+    ruq_in_goal(Goal,NewGoal1,Goal,replace_rules),
     (Goal == NewGoal1,!,NewGoal=NewGoal1
     ;
      normalize(NewGoal1,NewGoal)
-    ).   
+    ).
 
 user_def_rules(A,NewC,G,replace_rules) :- !,
-    replace_rule(_RuleName,C,C_Conds,D,D_Conds,AddC),       
+    replace_rule(_RuleName,C,C_Conds,D,D_Conds,AddC),
     check_atom(C,A,R),
     list_call(C_Conds),
     conj_member_strong(D,D_Conds,G,[]),
-    apply_equiv(R,AddC,NewC).                                 
+    apply_equiv(R,AddC,NewC).
 
 user_def_rules(A,NewC,G,infer_rules) :- !,
-    inference_rule(RuleName,C,C_Conds,D,D_Conds,E,AddC),  
+    inference_rule(RuleName,C,C_Conds,D,D_Conds,E,AddC),
     check_atom(C,A,_R),
     list_call(C_Conds),
     conj_member_strong(D,D_Conds,G,E),
     trace_firules(RuleName),
-    conj_append(AddC,A,NewC). 
- 
+    conj_append(AddC,A,NewC).
+
 user_def_rules(A,NewC,G,fail_rules) :- !,
-    fail_rule(RuleName,C,C_Conds,D,D_Conds,E),   
+    fail_rule(RuleName,C,C_Conds,D,D_Conds,E),
     check_atom(C,A,_R),
     list_call(C_Conds),
     conj_member_strong(D,D_Conds,G,E),
@@ -4948,29 +4948,29 @@ user_def_rules(A,NewC,G,fail_rules) :- !,
     conj_append((a = b),A,NewC).
 
 conj_member_strong([],_,_,_):- !.
-conj_member_strong([T],D_Conds,G,E):-    
+conj_member_strong([T],D_Conds,G,E):-
     conj_member_strong1(T,D_Conds,G,E),
     list_call(D_Conds),!.
-conj_member_strong([T|R],D_Conds,G,E):- 
+conj_member_strong([T|R],D_Conds,G,E):-
     R \== [],
     conj_member_strong1(T,D_Conds,G,E),
     conj_member_strong(R,D_Conds,G,E),!.
 
-conj_member_strong1(T,_D_Conds,(A & _Cj),E) :- 
+conj_member_strong1(T,_D_Conds,(A & _Cj),E) :-
     check_atom(T,A,_R),
-    list_ex(E,T). 
-conj_member_strong1(T,D_Conds,(_Y & RCj),E):- 
+    list_ex(E,T).
+conj_member_strong1(T,D_Conds,(_Y & RCj),E):-
     conj_member_strong1(T,D_Conds,RCj,E).
- 
-check_atom(T,A,no) :-    
+
+check_atom(T,A,no) :-
     A=T,!.
-check_atom(T,A,RuleId) :-  
-    equiv_rule(RuleId,T,T1),!,  
+check_atom(T,A,RuleId) :-
+    equiv_rule(RuleId,T,T1),!,
     A=T1.
 
 list_call([]) :- !.
 list_call([G|R]) :-
-    call(G), 
+    call(G),
     list_call(R).
 
 list_ex([],_).
@@ -4986,7 +4986,7 @@ apply_equiv(R,A & B,A & B1) :- !,
 apply_equiv(R,A,A1) :-
     equiv_rule(R,A,A1),!.
 apply_equiv(_R,A,A).
-    
+
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% New predicate generation
 
@@ -5003,7 +5003,7 @@ newpred(P,A,T):-
     P =.. [Pred|L].
 
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% transform_goal/2 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% transform_goal/2
 % Transform a goal from the external representation to the
 % internal representation, by rewriting intensional sets,
 % RUQs, set and bag terms
@@ -5014,7 +5014,7 @@ transform_goal(Goal_external,Goal_internal) :-
        preproc_goal(Goal_ruq,Goal),!,
        ruq_in_goal(Goal,Goal_internal).
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% transform_clause/2 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% transform_clause/2
 % Transform a clause from the external representation to the
 % internal representation, by rewriting intensional sets,
 % RUQs, set and bag terms
@@ -5026,26 +5026,26 @@ transform_clause(Clause_external,Clause_internal) :-
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%     Postprocessing 
+%%%%%%%%%%%%%%%%     Postprocessing
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-%%%%%%%%%%%%% Set (multiset) postprocessor:  
-%%%%%%%%%%%%% from 'with' ('mwith') to {...} (*({...})) notation  
+%%%%%%%%%%%%% Set (multiset) postprocessor:
+%%%%%%%%%%%%% from 'with' ('mwith') to {...} (*({...})) notation
 
-postproc(X,X):- 
-        var(X),!.      
+postproc(X,X):-
+        var(X),!.
 postproc(X,X):-
         atomic(X),!.
 postproc(X,Y):-
         nonvar(X), X = _ with _,!,
         norep_in_set(X,X1),
-        with_postproc(X1,Y). 
+        with_postproc(X1,Y).
 postproc(X,Y):-
         nonvar(X), X = _ mwith _,!,
         mwith_postproc(X,Z),
         mwith_out(Z,Y).
 postproc(X,Z):-
-        nonvar(X), 
+        nonvar(X),
         =..(X,[F|ListX]),
         postproc_all(ListX,ListZ),
         =..(Z,[F|ListZ]).
@@ -5055,20 +5055,20 @@ postproc_all([A|L1],[B|L2]):-
         postproc(A,B),
         postproc_all(L1,L2).
 
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set postprocessing 
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set postprocessing
 
 with_postproc(A,A) :- var(A),!.
 with_postproc(K,K):- is_ker(K), !.
 with_postproc(A,{}(B)):-
         postproc_list(A,B).
 
-%postproc_list(X with A1,(A2 \ X)) :-  
-postproc_list(X with A1,(A2 / X)) :-  
+%postproc_list(X with A1,(A2 \ X)) :-
+postproc_list(X with A1,(A2 / X)) :-
         var(X),!,postproc(A1,A2).
 postproc_list({} with A1,A2):- !,
         postproc(A1,A2).
-%postproc_list(K with A1,(A2 \ K)) :-  
-postproc_list(K with A1,(A2 / K)) :-  
+%postproc_list(K with A1,(A2 \ K)) :-
+postproc_list(K with A1,(A2 / K)) :-
         is_ker(K),!,postproc(A1,A2).
 postproc_list(B1 with A1,(A2,B2)):-
         postproc(A1,A2),postproc_list(B1,B2).
@@ -5082,8 +5082,8 @@ mwith_postproc({},{}):- !.
 mwith_postproc(A,{}(B)):-
     bag_postproc_list(A,B).
 
-%bag_postproc_list(X mwith A1,(A2 \ X)) :-   
-bag_postproc_list(X mwith A1,(A2 / X)) :-   
+%bag_postproc_list(X mwith A1,(A2 \ X)) :-
+bag_postproc_list(X mwith A1,(A2 / X)) :-
     var(X),!,postproc(A1,A2).
 bag_postproc_list({} mwith A, A):-
     var(A),!.
@@ -5097,9 +5097,9 @@ bag_postproc_list(B1 mwith A1,(A2,B2)):-
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%               
-%%%%%%%%%%%%%%     Auxiliary predicates     %%%%%%%%%%%%%%%%%               
-%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%               
+%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%     Auxiliary predicates     %%%%%%%%%%%%%%%%%
+%%%%%%%%%%%%%%                              %%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -5156,9 +5156,9 @@ bag_postproc_list(B1 mwith A1,(A2,B2)):-
 %%%%%%%%%%%%%%%%     List manipulation
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-list_term(T) :- 
-        nonvar(T), 
-        (T=[],! ; T=[_ | _]).  
+list_term(T) :-
+        nonvar(T),
+        (T=[],! ; T=[_ | _]).
 
 mklist([],0):- !.
 mklist([_|R],N):-
@@ -5173,24 +5173,24 @@ memberrest(X,[_|R],L):-
         memberrest(X,R,L).
 
 memberall(A,B,[A|_R],[B|_S]).
-memberall(A,B,[_|R],[_|S]):- 
+memberall(A,B,[_|R],[_|S]):-
         memberall(A,B,R,S).
 
-%append([],L,L).                                     
+%append([],L,L).
 %append([X|L1],L2,[X|L3]):-
 %       append(L1,L2,L3).
 
-member_strong(A,[B|_R]):- 
+member_strong(A,[B|_R]):-
          A == B, !.
-member_strong(A,[_|R]):- 
+member_strong(A,[_|R]):-
         member_strong(A,R).
 
 notin(_,[]).       % not member strong
 notin(A,[B|R]):-
         A \== B, notin(A,R).
 
-listunion([],L,L).   
-listunion([A|R],X,[A|S]):- 
+listunion([],L,L).
+listunion([A|R],X,[A|S]):-
         notin(A,X),!,
         listunion(R,X,S).
 listunion([_A|R],X,S):-
@@ -5213,30 +5213,30 @@ norep_in_list([A|R],[A|S]):-
 %%%%%%%%%%%%%%%%     Set manipulation
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-set_term(T) :- 
-       nonvar(T), 
-       (T={},! ; T=_ with _).     
+set_term(T) :-
+       nonvar(T),
+       (T={},! ; T=_ with _).
 
-is_set(S) :- set_term(S),!.  
-is_set(S) :- int_term(S).   
+is_set(S) :- set_term(S),!.
+is_set(S) :- int_term(S).
 
 tail(R,R) :- var(R),!.
 tail(R with _,R) :- var(R),!.
 tail({} with _,{}) :- !.
 tail(int(_A,_B) with _,{}) :- !.
 tail(ris(_,_,_,_,_),{}) :- !.     %ris
-tail(R with _,T) :- 
+tail(R with _,T) :-
        tail(R,T).
 
-bounded(T) :- 
+bounded(T) :-
        var(T),!,fail.
 bounded({}) :- !.
-bounded(R with _) :- 
+bounded(R with _) :-
        bounded(R).
 
 replace_tail(R,N,N) :- var(R),!.
 replace_tail({},N,N) :- !.
-replace_tail(R1 with X,N,R2 with X) :- 
+replace_tail(R1 with X,N,R2 with X) :-
        replace_tail(R1,N,R2).
 
 %%%% split(S,N,L) true if S is a set term of the form N with tn with ... with t1
@@ -5252,7 +5252,7 @@ norep_in_set(R with A,S):-
        set_member_strong(A,R),!,
        norep_in_set(R,S).
 norep_in_set(R with A,S with A):-
-       norep_in_set(R,S).        
+       norep_in_set(R,S).
 
 set_length(S,N) :-
        set_length(S,0,N).
@@ -5273,20 +5273,20 @@ set_member(X,R with _Y,C):-
 
 set_member_strong(A,B):-
        nonvar(B),
-       B = _ with X, 
+       B = _ with X,
        A == X,!.
 set_member_strong(A,B):-
-       nonvar(B), 
+       nonvar(B),
        B = Y with _,
        set_member_strong(A,Y).
 
 list_to_set(L,S,[]) :-            % list_to_set(+list,?set,-constraint)
-       var(S),!, 
-       mk_set(L,S).             
-list_to_set(L,S,C) :-            
-       mk_test_set(L,S,C).   
-          
-mk_set([],{}) :- !.             
+       var(S),!,
+       mk_set(L,S).
+list_to_set(L,S,C) :-
+       mk_test_set(L,S,C).
+
+mk_set([],{}) :- !.
 mk_set([X|L],R with X) :-
        mk_set(L,R).
 
@@ -5301,55 +5301,55 @@ mk_test_set([X|L],S,Cout) :-
 %%%%%%%%%%%%%%%%     Interval manipulation
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-int_term(T) :- 
-       nonvar(T), 
-       T=int(A,B), 
+int_term(T) :-
+       nonvar(T),
+       T=int(A,B),
        (var(A),! ; integer(A)),
-       (var(B),! ; integer(B)). 
+       (var(B),! ; integer(B)).
 
 is_int(T,A,B) :-                     % is_int(I,A,B) is true if I is a term that denotes an interval
        T=int(A,B),
-       nonvar(A), nonvar(B),      
-       integer(A), integer(B),!.     
-is_int(_T,_A,_B) :-  
+       nonvar(A), nonvar(B),
+       integer(A), integer(B),!.
+is_int(_T,_A,_B) :-
        fail.
 
 int_to_set(int(A,A),{} with A) :- !. % int_to_set(+I,?S) is true if S denotes the set
-int_to_set(int(A,B),S with A) :-     % of all elements of the interval I 
+int_to_set(int(A,B),S with A) :-     % of all elements of the interval I
        A < B,
        A1 is A + 1,
        int_to_set(int(A1,B),S).
 
 int_to_set(int(A,A),R with A,R) :- !.% int_to_set(+I,?S) is true if S contains the set
-int_to_set(int(A,B),S with A,R) :-   % of all elements of the interval I 
+int_to_set(int(A,B),S with A,R) :-   % of all elements of the interval I
        A < B,
        A1 is A + 1,
        int_to_set(int(A1,B),S,R).
 
 int_length(int(A,B),L) :-
        N is B - A + 1,
-      (N < 0,!, L = 0           
+      (N < 0,!, L = 0
        ;
        L = N
-       ).       
+       ).
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%     Bag manipulation
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-bag_term(T) :- 
-       nonvar(T), 
-       (T={},! ; T=_ mwith _).  
+bag_term(T) :-
+       nonvar(T),
+       (T={},! ; T=_ mwith _).
 
 bag_tail(R mwith _ ,R) :- var(R),!.
 bag_tail({} mwith _ ,{}) :- !.
-bag_tail(R mwith _ ,T) :- 
+bag_tail(R mwith _ ,T) :-
        bag_tail(R,T).
 
 de_tail(R,{}) :- var(R),!.
 de_tail({},{}) :- !.
-de_tail(R mwith S,K mwith S) :- 
+de_tail(R mwith S,K mwith S) :-
        de_tail(R,K).
 
 
@@ -5359,9 +5359,9 @@ de_tail(R mwith S,K mwith S) :-
 
 empty_aggr(A) :-                  % empty set/multiset/list
        (is_empty(A),! ; A == []).
-                                  
+
 is_empty({}) :- !.                % empty set (also specified as int(L,H) with L>H)
-is_empty(S) :- !,            
+is_empty(S) :- !,
        is_int(S,L,H),
        L > H.
 
@@ -5374,16 +5374,16 @@ aggr_comps([X | R],X,R).          % list
 %%%%%%%%%%%%%%%%  Arithmetic expressions manipulation
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-simple_integer_expr(E) :- 
+simple_integer_expr(E) :-
       (var(E),! ; integer(E)).
 
 simple_arithm_expr(E) :-
       (var(E),! ; number(E)).
 
-integer_expr(E) :-       % true if E is an integer expression       
+integer_expr(E) :-       % true if E is an integer expression
       on_exception(_Error,fd_eq(_X,E),(write('Problem in arithmetic expression'),nl,fail)).
 
-arithm_expr(E) :-        % true if E is a ground arithmetic expression       
+arithm_expr(E) :-        % true if E is a ground arithmetic expression
       on_exception(_Error,_X is E,(write('Problem in arithmetic expression'),nl,fail)).
 
 
@@ -5391,7 +5391,7 @@ arithm_expr(E) :-        % true if E is a ground arithmetic expression
 %%%%%%%%%%%%%%%%  Variable manipulation
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-samevar(X,Y) :- 
+samevar(X,Y) :-
       var(X), var(Y), X == Y.
 
 chvar(L1,[X|L1],X,L2,[Y|L2],Y):-
@@ -5403,23 +5403,23 @@ chvar(L1,L1new,(H :- B),L2,L2new,(H1 :- B1)):-
     chvar(L1a,L1new,B,L2a,L2new,B1).
 chvar(L1,L1new,(B1 & B2),L2,L2new,(B1a & B2a)):-
     !, chvar(L1,L1a,B1,L2,L2a,B1a),
-    chvar(L1a,L1new,B2,L2a,L2new,B2a).       
+    chvar(L1a,L1new,B2,L2a,L2new,B2a).
 chvar(L1,L1,F,L2,L2,F):-
     atomic(F),!.
 chvar(L1,L1new,F,L2,L2new,F1):-
     F =.. [Fname|Args],
     chvar_all(L1,L1new,Args,L2,L2new,Brgs),
     F1 =.. [Fname|Brgs].
-    
+
 chvar_all(L1,L1,[],L2,L2,[]).
 chvar_all(L1,L1b,[A|R],L2,L2b,[B|S]):-
     chvar(L1,L1a,A,L2,L2a,B),
     chvar_all(L1a,L1b,R,L2a,L2b,S).
-        
+
 find_corr(X,Y,[A|_R],[Y|_S]):-
-    X == A,!.    
+    X == A,!.
 find_corr(X,Y,[_|R],[_|S]):-
-    find_corr(X,Y,R,S).   
+    find_corr(X,Y,R,S).
 
 occurs(X,Y):-   % occur(X,T): true if variable X occurs in term T
        var(Y),samevar(X,Y),!.
@@ -5444,11 +5444,11 @@ occur_check_list(X,[A|R]):-
       occur_check_list(X,R).
 
 extract_vars(A,[A]):-
-    var(A),!.                 
+    var(A),!.
 extract_vars(exists(V,B),Vars):-
     var(V),!,
     extract_vars(B,List),
-    remove_var(V,List,Vars). 
+    remove_var(V,List,Vars).
 extract_vars(exists(V,B),Vars):-
     !,extract_vars(B,List),
     remove_list(V,List,Vars).
@@ -5456,46 +5456,46 @@ extract_vars(forall(X in Y,B),Vars):-
     !, extract_vars(Y,L1),
     extract_vars(B,L2),
     listunion(L1,L2,L),
-    remove_var(X,L,Vars).    
+    remove_var(X,L,Vars).
 extract_vars(Int,Vars):-
     is_sf(Int,X,G),!,
     extract_vars(G,Vars1),
-    remove_var(X,Vars1,Vars).   
+    remove_var(X,Vars1,Vars).
 extract_vars(P,Vars):-
     functor(P,_,A),
     !, findallvars(P,A,Vars).
-    
-findallvars(_P,0,[]):- !.   
+
+findallvars(_P,0,[]):- !.
 findallvars(P,A,Vars):-
     arg(A,P,Arg),
     extract_vars(Arg,L1),
     B is A-1,
     findallvars(P,B,L2),
     listunion(L1,L2,Vars).
-        
+
 remove_var(_,[],[]).
 remove_var(X,[Y|L],S):-
     X == Y,!,remove_var(X,L,S).
 remove_var(X,[Y|L],[Y|S]):-
-    remove_var(X,L,S).  
-        
+    remove_var(X,L,S).
+
 remove_list([],L,L).
 remove_list([X|R],Vars,Finalvars):-
     remove_var(X,Vars,S),
-    remove_list(R,S,Finalvars).   
+    remove_list(R,S,Finalvars).
 
 alldist([]).
 alldist([A|R]):-
     var(A), not_in_vars(A,R),
     alldist(R).
-    
+
 not_in_vars(_X,[]).
 not_in_vars(X,[A|R]):-
     X \== A, not_in_vars(X,R).
-   
+
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%  Conjunction manipulation 
+%%%%%%%%%%%%%%%%  Conjunction manipulation
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 list_to_conj(A & B,[A|R]):-
@@ -5503,7 +5503,7 @@ list_to_conj(A & B,[A|R]):-
 list_to_conj(true,[]):-!.
 list_to_conj(A,[A]).
 
-conj_append(Cj1,Cj2,(Cj1 & Cj2)) :-    
+conj_append(Cj1,Cj2,(Cj1 & Cj2)) :-
         var(Cj1),!.
 conj_append(true,Cj2,Cj2) :- !.
 conj_append((X & Cj1),Cj2,(X & Cj3)) :- !,
@@ -5515,15 +5515,15 @@ conj_append(X,Cj2,(X & Cj2)).
 %%%%%%%%%%%%%%%%% Configuration parameters %%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-path('').                         % the default path (= the working director '.')  
+path('').                         % the default path (= the working director '.')
 
-rw_rules('setlog_rules.pl').      % the default library of filtering rules    
+rw_rules('setlog_rules.pl').      % the default library of filtering rules
 
-strategy(cfirst).                 % the default atom selection strategy (= "constraint first") 
-%strategy(cfirst(UserPredList)).  % UserPredList is a list of user defined predicates to be 
+strategy(cfirst).                 % the default atom selection strategy (= "constraint first")
+%strategy(cfirst(UserPredList)).  % UserPredList is a list of user defined predicates to be
                                   % executed just after constraint solution (before all other
                                   % user-defined predicates)
-                                  % e.g., strategy(cfirst([ttf_list(_),ttf_nat(_),ttf_int(_),ttf_btype(_)])).       
+                                  % e.g., strategy(cfirst([ttf_list(_),ttf_nat(_),ttf_int(_),ttf_btype(_)])).
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -5532,6 +5532,6 @@ strategy(cfirst).                 % the default atom selection strategy (= "cons
 
 %:- setlog(consult_lib,_).
 
-:- load_rwrules_lib.     % load the library of filtering rules  
+:- load_rwrules_lib.     % load the library of filtering rules
 
 %:- nl,write('Use ?- setlog_help to get help information about {log}'),nl,nl.
diff --git a/share/setlog_rules.pl b/share/setlog_rules.pl
index 1fc68f1..464a270 100644
--- a/share/setlog_rules.pl
+++ b/share/setlog_rules.pl
@@ -28,18 +28,18 @@ filter_on.
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 
-%%%%%%%%%%%%%%%%%%%%%%%% equivalence rules 
+%%%%%%%%%%%%%%%%%%%%%%%% equivalence rules
 
-% equiv_rule(A,B), with A, B {log} predicates: if the input goal contains B then  
+% equiv_rule(A,B), with A, B {log} predicates: if the input goal contains B then
 % then B matches with both filtering rules for A and filtering rules for B (since B => A)
 
 :- op(700,xfx,[ein,enin]).
 
-equiv_rule(e2,inters(X,Y,Z),dinters(X,Y,Z)).     % e2. dinters(X,Y,Z) => inters(X,Y,Z)   
-equiv_rule(e3,ssubset(X,Y),dssubset(X,Y)).       % e3. dssubset(X,Y) => ssubset(X,Y)   
-equiv_rule(e4,nsubset(X,Y),dnsubset(X,Y)).       % e4. dnsubset(X,Y) => nsubset(X,Y)   
-equiv_rule(e5,X in Y,X ein Y).                   % e5. X ein Y => X in Y   
-equiv_rule(e6,X nin Y,X enin Y).                 % e6. X enin Y => X nin Y  
+equiv_rule(e2,inters(X,Y,Z),dinters(X,Y,Z)).     % e2. dinters(X,Y,Z) => inters(X,Y,Z)
+equiv_rule(e3,ssubset(X,Y),dssubset(X,Y)).       % e3. dssubset(X,Y) => ssubset(X,Y)
+equiv_rule(e4,nsubset(X,Y),dnsubset(X,Y)).       % e4. dnsubset(X,Y) => nsubset(X,Y)
+equiv_rule(e5,X in Y,X ein Y).                   % e5. X ein Y => X in Y
+equiv_rule(e6,X nin Y,X enin Y).                 % e6. X enin Y => X nin Y
 
 %TO BE COMPLETED: esubset, einters, ...
 
@@ -53,7 +53,7 @@ equiv_rule(e6,X nin Y,X enin Y).                 % e6. X enin Y => X nin Y
 %     D: list of other atomic constraints to be checked
 %     D_Conds: list of conditions for atomic constraints in D and C
 %     AddC: constraint to be replaced to C)
-        
+
 %%%%% general
 
 % t = X -replace-> X = t
@@ -64,27 +64,27 @@ replace_rule(br3,T=X,[var(X),nonvar(T)],[],[],X=T).
 % inters(X,{...},t3) -replace-> inters({...},X,t3)
 replace_rule(r3,inters(X,T2,T3),[var(X),nonvar(T2)],[],[],inters(T2,X,T3)).
 
-% A neq B & set(A) & set(B) -replace-> (X in A & X nin B or X nin A & X in B) 
+% A neq B & set(A) & set(B) -replace-> (X in A & X nin B or X nin A & X in B)
 replace_rule(r4,A neq B,[var(A),var(B)],[set(A1),set(B1)],[A1==A,B1==B],(X in A & X nin B or X nin A & X in B)).
 
-% A neq {...} & set(A) -replace-> (X in A & X nin {...} or X nin A & X in {...}) 
+% A neq {...} & set(A) -replace-> (X in A & X nin {...} or X nin A & X in {...})
 replace_rule(r4,A neq B,[var(A),nonvar(B),B=_ with _],[set(A1)],[A1==A],(X in A & X nin B or X nin A & X in B)).
 
-% {...} neq B & set(B) -replace-> (X in B & X nin {...} or X nin B & X in {...}) 
+% {...} neq B & set(B) -replace-> (X in B & X nin {...} or X nin B & X in {...})
 replace_rule(r4,A neq B,[var(B),nonvar(A),A=_ with _],[set(B1)],[B1==B],(X in A & X nin B or X nin A & X in B)).
 
-%%%%% relations/partial functions    
+%%%%% relations/partial functions
 
-% dom(Rel,Dom) & pfun(Rel) -replace-> dompf(Rel,Dom)  & pfun(Rel)   
+% dom(Rel,Dom) & pfun(Rel) -replace-> dompf(Rel,Dom)  & pfun(Rel)
 replace_rule(br4,dom(Rel,Dom),[var(Rel)],[pfun(Rel1)],[Rel1==Rel],dompf(Rel,Dom)).
 
 % comp(R,S,Q) & pfun(R) & pfun(S) -replace-> comppf(R,S,Q) & pfun(Q) & pfun(R) & pfun(S)
 replace_rule(br5,comp(R,S,Q),[var(R),var(S)],[pfun(R1),pfun(S1)],[R1==R,S1==S],comppf(R,S,Q) & pfun(Q)).
 
-% dres(A,R,S) & pfun(R) -replace-> drespf(A,R,S) & pfun(R)  
+% dres(A,R,S) & pfun(R) -replace-> drespf(A,R,S) & pfun(R)
 replace_rule(br6,dres(A,R,S),[var(R)],[pfun(R1)],[R1==R],drespf(A,R,S)).
 
-% rel(R) & pfun(R) -replace-> pfun(R) & pfun(R)    
+% rel(R) & pfun(R) -replace-> pfun(R) & pfun(R)
 replace_rule(br7,rel(R),[var(R)],[pfun(R1)],[R1==R],pfun(R)).
 
 %un(S,T,cp(A,A)) -replace-> delay(un(S,T,cp(A,A)),false)
@@ -120,7 +120,7 @@ replace_rule(br2,X =< Y,[var(X),var(Y)],[],[],Y >= X).
 %     D_Conds: list of conditions for atomic constraints in D and C
 %     E: list of constraints in D to be NOT checked
 %     AddC: constraint to be added)
-        
+
 %%%%% sets
 
 %inters(X,Y,Z) & un(X,Y,Z)  -+->   X = Y & Y = Z
@@ -145,7 +145,7 @@ inference_rule('length-length',length(L,N),[var(L)],[length(L1,M)],[L1==L],[leng
 
 % X > Y & Y > Z -add-> X > Z
 inference_rule('gt-gt',X > Y,[var(X),var(Y)],[Y1 > Z],[Y1==Y,Z\==X],[X > Y], X > Z).
-        
+
 % X >= Y & Y >= X -add-> X = Y
 inference_rule('ge-ge',X >= Y,[var(X),var(Y)],[Y1 >= X1],[Y1==Y,X1==X],[], X = Y).
 
@@ -172,16 +172,16 @@ inference_rule('sum-sum',X is Y + K,[var(X),var(Y),integer(K)],[Z is Y1 + K1],[v
 fail_rule('gt-gt',X > Y,[],[V > W],[V==Y,W==X],[]).
 % it works also for X > X
 
-% bf2. X >= Y & Y > X 
+% bf2. X >= Y & Y > X
 fail_rule('ge-gt',X >= Y,[],[V > W],[V==Y,W==X],[]).
 
 %%%%% sets
 
-% bf3. X in S & X nin S 
+% bf3. X in S & X nin S
 fail_rule('in-nin',X in S,[var(S)],[X1 nin S1],[X1==X,S1==S],[]).
 
 % bf4. NotSubsetOfSingleton
-% A neq {} & ssubset(A,{X})            
+% A neq {} & ssubset(A,{X})
 fail_rule('NotSubsetOfSingleton',ssubset(A,S),[nonvar(S),S={} with _X],[A1 neq E],[nonvar(E),E={},A1==A],[]).
 
 %%%%% intervals (terminating, provided all variables have "not too big" domains)
@@ -191,7 +191,7 @@ fail_rule('NotSubsetOfSingleton',ssubset(A,S),[nonvar(S),S={} with _X],[A1 neq E
 fail_rule('NatRangeNotEmpty',I=int(X,Y),[var(X),var(Y)],[X1 is Expr1,Y1 is Expr2,I1=E],[nonvar(Expr1),Expr1=(Z+A),integer(A),nonvar(Expr2),Expr2=(Z1+B),integer(B),A=<B,nonvar(E),E={},X1==X,Y1==Y,Z1==Z,I1==I],[]).
 
 % f21. NatRangeNotEq3
-% I=int(X,Y) & J=int(a,b) & I=J & X is Z+N & Y is Z+M & N is V*h & M =< P & P is W*h & W is V+k  
+% I=int(X,Y) & J=int(a,b) & I=J & X is Z+N & Y is Z+M & N is V*h & M =< P & P is W*h & W is V+k
 % and a,b,h,k integer constants >= 0 and it holds that b-a > k*h
 %
 fail_rule('NatRangeNotEq3',I=int(X,Y),
@@ -219,7 +219,7 @@ fail_rule('NatRangeNotSubset',I=int(X,Y),
                    I==I1,J==J1,X==X1,Y==Y1,N==N1,M==M1,Za=Za1,Zb==Zb1,Zc==Zc1],[]).
 
 % f23. NatRangeNotEq
-% I=int(X,Y) & J=int(Kn,Km) & I=J & X is N+Za & Y is N+Zb & Za is M*Kp & Zb is Zc*Kp & Zc is M+Kq 
+% I=int(X,Y) & J=int(Kn,Km) & I=J & X is N+Za & Y is N+Zb & Za is M*Kp & Zb is Zc*Kp & Zc is M+Kq
 % with Km-Kn > Kq*Kp
 %
 fail_rule('NatRangeNotEq',I=int(X,Y),
@@ -260,9 +260,9 @@ fail_rule('NatRangeNotEmpty4',I=int(N,Y),
 
 % Add here other more specific user-defined rewriting rules
 
- 
+
 %%%%%%%%%%%%%%%%%%%%%%%% for the TTF
- 
-:- (exists_file('TTF_rules.pl'),!,consult('TTF_rules.pl') 
-    ; 
+
+:- (exists_file('TTF_rules.pl'),!,consult('TTF_rules.pl')
+    ;
     true).
-- 
GitLab