(* token is a couple of a family number and a star number in the constellation *)
typetoken=int*int
typeprocess=tokenlist
(* get a star using its number in the list from a constellation *)
letget_starconsti=
letget_starconsti=
List.nthconsti
List.nthconsti
(* Takes a constellation, a ray and a (ray,ray) list and extracts rays from stars number i (respectively j) that are not ri (respectively rj) when ri (respectively rj) isn't in the prob list *)
(* Takes a constellation, a ray and a (ray,ray) list and extracts rays from stars number i (respectively j) that are not ri (respectively rj) when ri (respectively rj) isn't in the prob list *)
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 *)
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*)
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))(*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 *)
letrecaux(toklist,prob,star,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
beginmatchtoklistwith
|[]->(*let gen_token = List.filter (fun ((i,_),(_,_)) -> not( List.mem i checked_stars)) graph in *)
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 *)
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
elseletsigma_xy=[(id,term)]in
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 *)
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 *)