Commit c18b8b05 authored by Pietro Abate's avatar Pietro Abate

Fix multiple bugs in the function Tallying.norm

parent 410fcd0c
......@@ -189,5 +189,5 @@ module Var (X : T) = struct
let equal t1 t2 = (compare t1 t2) = 0
let dump ppf = function
|`Atm x -> X.dump ppf x
|`Var x -> String.dump ppf x
|`Var x -> Format.fprintf ppf "`$%a" String.dump x
end
......@@ -9,8 +9,23 @@ let parse_typ s =
Types.descr nodepat
;;
let cup = Types.Tallying.CS.S.cup
let cap = Types.Tallying.CS.cap
let singleton = Types.Tallying.CS.singleton
let norm_tests = [
"Int \\ (`$A | `$B)", [[(false,`Var "A",parse_typ "Int \\ `$B")]];
"Int \\ (`$A | `$B)", singleton (false,`Var "A",parse_typ "Int \\ `$B");
"(`$A -> Int) \\ (`$B -> `$B)",
cup
(singleton (true,`Var "B",parse_typ "Empty"))
(cap
(singleton (false , `Var "B",parse_typ "`$A"))
(singleton (false , `Var "B",parse_typ "Int"))
);
"`$B", singleton (true,`Var "B",parse_typ "Empty");
"`$B \\ `$A", singleton (false , `Var "B",parse_typ "`$A");
"Int \\ `$B", singleton (false , `Var "B",parse_typ "Int");
"(Int & Bool -> Int) \\ (`$A -> `$B)"
]
let test_norm =
......
......@@ -42,6 +42,7 @@ sig
val cap : t -> t -> t
val diff : t -> t -> t
val atom : elem -> t
val neg_atom : elem -> t
(* vars a : return a bdd that is ( Any ^ Var a ) *)
val vars : Custom.var -> t
......@@ -54,7 +55,7 @@ sig
val is_empty : t -> bool
val print: string -> t -> (Format.formatter -> unit) list
val print: ?f:(Format.formatter -> elem -> unit) -> t -> (Format.formatter -> unit) list
val trivially_disjoint: t -> t -> bool
......@@ -189,10 +190,10 @@ struct
| `False -> ()
| _ -> b (); Format.fprintf ppf "@[~%a@] & @[(%a)@]" f x (print f) n)
let print a = function
| `True -> [ fun ppf -> Format.fprintf ppf "%s" a ]
| `False -> []
| c -> [ fun ppf -> print X.dump ppf c ]
let print ?(f=X.dump) = function
| `True -> [] (* [] a bdd cannot be of this type *)
| `False -> [ fun ppf -> Format.fprintf ppf "Empty" ]
| c -> [ fun ppf -> print f ppf c ]
(* return a list of pairs, where each pair holds the list
* of positive and negative elements on a branch *)
......
This diff is collapsed.
......@@ -355,6 +355,7 @@ module Tallying : sig
module M : Map.S with type key = key
module S : Set.S with type elt = t M.t
type cset = S.t
val print : Format.formatter -> S.t -> unit
val merge : S.elt -> S.elt -> S.elt
val singleton : constr -> cset
val sat : cset
......@@ -364,5 +365,7 @@ module Tallying : sig
end
val norm : t -> CS.cset
val merge : CS.S.elt -> CS.cset
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment