]> matita.cs.unibo.it Git - helm.git/commitdiff
an optimization was inserted
authorFerruccio Guidi <ferruccio.guidi@unibo.it>
Wed, 4 Feb 2004 18:44:43 +0000 (18:44 +0000)
committerFerruccio Guidi <ferruccio.guidi@unibo.it>
Wed, 4 Feb 2004 18:44:43 +0000 (18:44 +0000)
helm/ocaml/mathql/.depend
helm/ocaml/mathql/avs.ml
helm/ocaml/mathql/avsUtil.ml
helm/ocaml/mathql/avsUtil.mli
helm/ocaml/mathql/listAvs.ml

index 6d18bd83cc2e0a71f7bcb34688a65eb53e8137ff..8aa1d9b8dc874387cf5cff60986a334278f3ded8 100644 (file)
@@ -1,10 +1,10 @@
 listAvs.cmi: avs.cmo 
 avsUtil.cmi: mathQL.cmo 
+mQueryUtil.cmo: mQueryUtil.cmi 
+mQueryUtil.cmx: mQueryUtil.cmi 
 listAvs.cmo: avs.cmo listAvs.cmi 
 listAvs.cmx: avs.cmx listAvs.cmi 
 mathQL.cmo: avs.cmo listAvs.cmi 
 mathQL.cmx: avs.cmx listAvs.cmx 
-avsUtil.cmo: mathQL.cmo avsUtil.cmi 
-avsUtil.cmx: mathQL.cmx avsUtil.cmi 
-mQueryUtil.cmo: mQueryUtil.cmi 
-mQueryUtil.cmx: mQueryUtil.cmi 
+avsUtil.cmo: mQueryUtil.cmi mathQL.cmo avsUtil.cmi 
+avsUtil.cmx: mQueryUtil.cmx mathQL.cmx avsUtil.cmi 
index 485354037ae949b6b47ceac26d68f06db1d66476..7b092a93557c735221ed5f0cec1abb960fcee468 100644 (file)
@@ -76,10 +76,10 @@ module type Type = sig
 
    val diff       : avs -> avs -> avs
 
-   val append     : avs -> avs -> avs
-
    val d_union    : avs -> avs -> avs (* with attr. distribution *)
 
    val peek       : avs -> peek_t
 
+   val optimize   : avs -> avs
+
 end
index 65bcadb15e3c46d8900cd702b7235dfd19610a84..1f01997722c17e646a1b44aac9dc8859a1c864a5 100644 (file)
@@ -52,24 +52,25 @@ let val_true = avs_of_bool true
 (* iterators ****************************************************************)
 
 let grp_iter f al =
-   List.fold_left (fun s a -> I.grp_union s (f a)) I.grp_empty al
+   List.fold_left (fun s a -> I.grp_union s (f a)) I.grp_empty (List.rev al)
 
 let grp_iter2 f al bl = 
-   List.fold_left2 (fun s a b -> I.grp_union s (f a b)) I.grp_empty al bl
+   List.fold_left2 (fun s a b -> I.grp_union s (f a b)) 
+                   I.grp_empty (List.rev al) (List.rev bl)
 
-let iter f al = List.fold_left (fun s a -> I.union s (f a)) I.empty al
-
-let append_iter f al = List.fold_left (fun s a -> I.append (f a) s) I.empty al
+let iter f al = List.fold_left (fun s a -> I.union s (f a)) 
+                               I.empty (List.rev al)
 
 (* other ********************************************************************)
 
 let grp_make_x p vl = grp_iter (I.grp_make p) vl
 
 let x_grp_make_x p rs = 
-   let aux g s _ = I.grp_make p s in
+   let aux g s _ = I.grp_union g (I.grp_make p s) in
    I.iter aux I.grp_empty rs
 
-let make_x s gl = iter (I.make s) gl
+let make_x s gl = 
+   if gl = [] then avs_of_string s else iter (I.make s) gl
 
 let count v = I.iter (fun n _ _ -> succ n) 0 v
 
index ac8888c171b57dbedc3b097e4f063bf8ac87dee8..886b6ca6c58bde2b55143f7f39808bee8383ecb8 100644 (file)
@@ -45,8 +45,6 @@ val make_x        : string -> MathQL.group list -> MathQL.result
 
 val iter          : ('a -> MathQL.result) -> 'a list -> MathQL.result
 
-val append_iter   : ('a -> MathQL.result) -> 'a list -> MathQL.result
-
 val count         : MathQL.result -> int
 
 val avs_of_bool   : bool -> MathQL.result 
index e25fc61c730975236bd11137672a97def63308d5..591dc3fe296c41dd06054220357ef9d51afecbc8 100644 (file)
@@ -133,8 +133,13 @@ let rec union s1 s2 =
 let grp_union = union
 
 let prod g1 g2 =
-   let aux a = set_iter (fun h -> [union a h]) g2 in
-   set_iter aux g1      
+   match g1, g2 with
+      | [], [] -> []
+      | _, []  -> g1
+      | [], _  -> g2
+      | _, _   ->
+         let aux a = set_iter (fun h -> [union a h]) g2 in
+         set_iter aux g1      
 
 let rec d_union s1 s2 =
    match s1, s2 with
@@ -177,13 +182,13 @@ let rec diff s1 s2 =
       | (r1, _) :: _, (r2, _) :: t2 when r1 > r2  -> diff s1 t2
       | _ :: t1, _ :: t2                          -> diff t1 t2
 
-(* concatenation ************************************************************)
-
-let append v1 v2 = v1 @ v2
-
 (* peeking ******************************************************************)
 
 let peek = function
    | []           -> Empty
    | [s, gl]      -> Single (s, gl)
    | (s, gl) :: _ -> Many (s, gl)
+
+(* optimization *************************************************************)
+
+let optimize = List.rev