From 88333aeb79f693c73e880e433fa6bcb33d715193 Mon Sep 17 00:00:00 2001 From: Claudio Sacerdoti Coen Date: Mon, 2 Mar 2009 23:36:00 +0000 Subject: [PATCH] New version. --- .../contribs/formal_topology/bin/comb.ml | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/helm/software/matita/contribs/formal_topology/bin/comb.ml b/helm/software/matita/contribs/formal_topology/bin/comb.ml index e0c58dec0..895273ce8 100755 --- a/helm/software/matita/contribs/formal_topology/bin/comb.ml +++ b/helm/software/matita/contribs/formal_topology/bin/comb.ml @@ -1,3 +1,10 @@ +(* 0: 7 + 1: 29 + 2: 120 + 3: > 319 + 4: ??? +*) + type t = M | I | C type w = t list type eqclass = w list @@ -93,7 +100,7 @@ let step (l : w list) = (List.map (function w -> List.map (fun x -> x@w) - (if List.length (List.filter (fun w -> w = M) w) >= 2 then + (if List.length (List.filter (fun w -> w = M) w) >= 1 then [[I];[C];[]] else [[I];[C];[M];[]]) @@ -208,12 +215,11 @@ let string_compare s1 s2 = if c = 0 then String.compare s1 s2 else c ;; -let normalize_and_describe norm mk_vertex dsc_vertex = +let normalize_and_describe norm dsc_vertex = let cache = Hashtbl.create 5393 in let canonicals = Hashtbl.create 5393 in let descriptions = Hashtbl.create 5393 in - (function n -> - let v = mk_vertex n in + (function v -> let normalized = norm v in let dsc = dsc_vertex v in if not (List.mem dsc (Hashtbl.find_all cache normalized)) then @@ -248,20 +254,19 @@ let classify arcs = print_endline (string_of_int (List.length arcs) ^ " arcs to be classified"); let mk_vertex,dsc_vertex = mk_vertex_and_dsc_vertex () in let graph = Graph.Pack.Digraph.create () in - iteri - (fun (x,y) -> - Graph.Pack.Digraph.add_edge graph (mk_vertex x) (mk_vertex y)) arcs; + let varcs = mapi (fun (x,y) -> mk_vertex x,mk_vertex y) arcs in + iteri (fun (x,y) -> Graph.Pack.Digraph.add_edge graph x y) varcs; print_endline (""); let classes,norm = Graph.Pack.Digraph.Components.scc graph in print_endline (string_of_int classes ^ " classes"); print_endline ("-----"); - norm,mk_vertex,dsc_vertex,arcs + norm,dsc_vertex,varcs ;; -let analyze (norm,mk_vertex,dsc_vertex,arcs) = +let analyze (norm,dsc_vertex,arcs) = print_endline ("building class graph (" ^ string_of_int (List.length arcs) ^ ")"); let normalize,finish,describe = - normalize_and_describe norm mk_vertex dsc_vertex in + normalize_and_describe norm dsc_vertex in let arcs = uniq (mapi (fun (x,y) -> normalize x,normalize y) arcs) in let cgraph = Graph.Pack.Digraph.create () in @@ -284,5 +289,5 @@ let rec iter n l = else analyze pkg in - iter 10 [[]] + iter 6 [[]] ;; -- 2.39.2