|
|
|
@ -92,6 +92,9 @@ let print_dgraph dg =
|
|
|
|
|
| h::t -> (link_to_string h) ^ "\n" ^ aux t |
|
|
|
|
in print_string (aux dg);; |
|
|
|
|
|
|
|
|
|
let clean_dgraph g = |
|
|
|
|
List.filter (fun a -> a <> []) g |
|
|
|
|
|
|
|
|
|
(* _________ Examples _________ *) |
|
|
|
|
let make_const_pol pol c = Func (c, pol, []) |
|
|
|
|
let make_const c = make_const_pol Npol c |
|
|
|
@ -149,11 +152,42 @@ let exec2 graph const =
|
|
|
|
|
| (_,(None,_)) -> None |
|
|
|
|
in aux2 h sol |
|
|
|
|
in aux graph (Some [],[]) ;; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exec (dgraph constellation) constellation;; |
|
|
|
|
exec2 (dgraph constellation) constellation;; |
|
|
|
|
(* token is a couple of a family number and a star number in the constellation *) |
|
|
|
|
type token = int * int |
|
|
|
|
type process = token list |
|
|
|
|
|
|
|
|
|
(* get a star using its number in the list from a constellation *) |
|
|
|
|
let get_star i const = |
|
|
|
|
List.nth const i |
|
|
|
|
|
|
|
|
|
(* takes a token, a graph and a constellation and returns the list of tokens to check next and a list of solvable equation *) |
|
|
|
|
let divide_token (fam, n_star) graph const = |
|
|
|
|
let rec aux g toklist prob = |
|
|
|
|
match g with |
|
|
|
|
| [] -> Some (toklist,prob) |
|
|
|
|
| h::t -> let links = List.filter (fun ((i, _),(_, _)) -> i = n_star) h in |
|
|
|
|
let rec aux2 l tokl probb = |
|
|
|
|
match l with |
|
|
|
|
| [] -> Some (toklist,prob) |
|
|
|
|
| ((i, j),(ri,rj))::tl -> |
|
|
|
|
if Option.is_some (solve ((ray_to_term (inv_pol_ray ri), ray_to_term rj)::probb) []) then |
|
|
|
|
aux2 tl ((fam, j)::tokl) ((ray_to_term (inv_pol_ray ri), ray_to_term rj)::probb) |
|
|
|
|
else None |
|
|
|
|
in if links = [] then aux t toklist prob else aux2 links toklist prob |
|
|
|
|
in aux graph [] [] |
|
|
|
|
|
|
|
|
|
(* should be deterministic exec, graph shouldn't be empty *) |
|
|
|
|
let exec const = |
|
|
|
|
let graph = clean_dgraph (dgraph const) in |
|
|
|
|
let rec aux (toklist,prob) = |
|
|
|
|
begin match toklist with |
|
|
|
|
| [] -> prob |
|
|
|
|
| h::t -> aux (Option.get (divide_token h graph const)) |
|
|
|
|
end |
|
|
|
|
in let ((i,_),(_,_)) = (List.hd (List.hd graph)) in aux ([(0,i)],[]) |
|
|
|
|
|
|
|
|
|
(* test constellation cyclique déterministe *) |
|
|
|
|
let boucle = [ [Func("c", Neg, [x]); x] ; [Func("c", Pos, [Func("f", Npol, [y])]) ; Func("c", Npol, [x]) ] ] ;; |
|
|
|
|
print_dgraph (dgraph boucle);; |
|
|
|
|
let test = [ [Func("c", Neg, [x]); x] ; [Func("c", Pos, [Func("f", Npol, [y])]) ; Func("c", Npol, [x]) ] ] ;; |
|
|
|
|
print_dgraph (dgraph test);; |
|
|
|
|
exec test ;; |