let identify_variables unif_std tas (std_subs : t_subst list)
(var_identif : t_partition) (vi_ctrs : t_vi_ctrs)
: (t_subst list * t_partition * (int * int) list) list =
let add_vi_ctr ((equations, vis) : t_vi_ctrs) (n : int) (m : int) =
((n,m)::equations, vis)
in
let rec help n tas (vi_ctrs : t_vi_ctrs) = function
| (m::_)::tail ->
(if is_allowed var_identif n m vi_ctrs then
let var_identif = combine_classes var_identif m n
in
(if is_allowed_vi var_identif vi_ctrs then
let std_subs2 = unif_std false (Var(m)) (Var(n)) std_subs
in
(if std_subs2 = [] then
help n tas (add_vi_ctr vi_ctrs n m) tail
else
let std_subs2_vi = (std_subs2, var_identif, fst vi_ctrs)
in
help n (std_subs2_vi::tas) (add_vi_ctr vi_ctrs n m) tail
)
else
help n tas vi_ctrs tail
)
else
help n tas vi_ctrs tail
)
| [] -> (tas, vi_ctrs)
| _ -> failwith ("identify_variables: var_identif is not a valid "^
"partition, it contains an empty class")
in
let rec help2 tas vi_ctrs = function
| (n::_)::tail ->
let (tas,vi_ctrs2) = help n tas vi_ctrs tail in
help2 tas vi_ctrs2 tail
| [] -> tas
| _ -> failwith ("identify_variables: var_identif is not a valid "^
"partition, it contains an empty class")
in
help2 tas vi_ctrs var_identif