iffam>(List.lengthprob_aux)||prob_aux=[]then(* We check if the family number is the same as the number of equations lists in prob. If it's superior, we add a new list in prob instead of filling the first equation list because it means we're treating a new family *)
auxtl((fam,j)::tokl)(((ri,rj)::(List.hdprob_aux))::(List.tlprob_aux))(((star_filterconst((i,j),(ri,rj))(List.hdprob_aux))@(List.hdstar_aux))::(List.tlstar_aux))(i::checked_stars_aux)(*We use List.hd because the current family we're working on should be the current first*)
letrecaux(toklist,prob,star,checked_stars,current_fam)=(*toklist is a list of tokens (int of family number and the number of a star), prob is the current list of equations, current_fam is the current family number *)
beginmatchtoklistwith
|[]->(*let gen_token = List.filter (fun ((i,_),(_,_)) -> not( List.mem i checked_stars)) graph in *)
iffam>(List.lengthprob2)||prob2=[]then(* We check if the family number is the same as the number of equations lists in prob. If it's superior, we add a new list in prob instead of filling the first equation list *)
aux2tl((fam,j)::tokl)(((ri,rj)::(List.hdprob2))::(List.tlprob2))(((star_filterconst((i,j),(ri,rj))(List.hdprob2))@(List.hdstar2))::(List.tlstar2))(i::checked_stars2)(*We use List.hd becasue the current family we're working on should be the current first*)
|(Var(x),term)::t->ifVar(x)=termthen(solvetsub)else(elimxtermtsub)(* If x = x it's a useless equation *)
|(term,Var(x))::t->(elimxtermtsub)(*It's useless to check if term = Var(x) because it would be the same case as above *)
|(Func(f,fs),Func(g,gs))::t->iff=gthen(solve((List.combinefsgs)@t)sub)elseNone(* If f and g are not equal, the equation can't be solved *)
|(Func(f,fs),Func(g,gs))::t->iff=gthen(solve((List.combinefsgs)@t)sub)else(*failwith (Printf.sprintf "f=%s g=%s" f g)*)None(* If f and g are not equal, the equation can't be solved *)
andelimidtermeqsub=
ifoccursidtermthenNone(* If that's the cas, we would have something like x = f(x) which can't be solved *)
ifoccursidtermthen(*failwith (Printf.sprintf "id=%s is in term" id)*)None(* If that's the case, we would have something like x = f(x) which can't be solved *)
elseletsigma_xy=[(id,term)]in
(solve(List.map(fun(a,b)->(substitasigma_xy,substitbsigma_xy))eq)(sigma_xy@sub))(* We apply the sigma_xy substitution and we add it to the solution list *)
solve(List.map(fun(a,b)->(substitasigma_xy,substitbsigma_xy))eq)((List.map(fun(i,t)->(i,substittsigma_xy))sub)@sigma_xy)(* We apply the sigma_xy substitution to the equations and the solution list and we add it to the solution list *)