let rec process_layer
unif_std
unif_nonstd
(xor_eqns : term list list )
(rem_ls : t_equal )
(ctr : t_unequal )
(nextlayer : (t_subst list * t_partition * (int * int) list) list)
(nextlayer_ctrs : t_partition list )
(vi_layer_ctrs : t_partition list )
(tas : t_subst list )
: (t_subst list * t_partition * (int * int) list) list
-> t_subst list =
function
| (std_subs,vi,vi_unequal_ctrs)::tail ->
(* solve problem for this vi, add solutions to tas and add the subst
* that fail to failed *)
let (subs,failed) =
process_layer_elem unif_std unif_nonstd vi
(vi_unequal_ctrs,vi_layer_ctrs)
xor_eqns rem_ls ctr [] [] std_subs
in
let tas = merge tas subs
in
(* do identification for failed, add it to nextlayer and
add vi to nextlayer_ctrs, if no substituition failed *)
let nextlayer =
if failed=[] then
nextlayer
else
identify_variables unif_std nextlayer failed vi
(vi_unequal_ctrs,vi_layer_ctrs)
in
let nextlayer_ctrs =
if failed=[] && subs<>[] then
vi::nextlayer_ctrs
else
nextlayer_ctrs
in
(* proceed with tail *)
process_layer unif_std unif_nonstd xor_eqns rem_ls ctr nextlayer
nextlayer_ctrs vi_layer_ctrs tas tail
| [] ->
(* this layer is finished, proceed with nextlayer, if this is not empty
*)
if nextlayer=[] then
tas
else
(* start with an empty nextlayer, the new vi_layer_ctrs are the former
* nextlayer_ctrs *)
process_layer unif_std unif_nonstd xor_eqns rem_ls ctr []
nextlayer_ctrs nextlayer_ctrs tas nextlayer