end
type t = Node.t
-let hash x = x.Node.key
+let hash x = x.Node.hash
let uid x = x.Node.id
let equal = Node.equal
let expr f = f.Node.node.pos
match dir with
| `Left -> Pretty.down_arrow, Pretty.subscript 1
| `Right -> Pretty.down_arrow, Pretty.subscript 2
+ | `Epsilon -> Pretty.epsilon, ""
+ | `Up1 -> Pretty.up_arrow, Pretty.subscript 1
+ | `Up2 -> Pretty.up_arrow, Pretty.subscript 2
in
fprintf fmt "%s%s" a_str d_str;
State.print fmt s;
let is_false f = (expr f) == False
-let cons pos neg s1 s2 size1 size2 =
- let nnode = Node.make { pos = neg; neg = (Obj.magic 0); st = s2; size = size2 } in
- let pnode = Node.make { pos = pos; neg = nnode ; st = s1; size = size1 } in
+let cons pos neg =
+ let nnode = Node.make { pos = neg; neg = (Obj.magic 0); } in
+ let pnode = Node.make { pos = pos; neg = nnode } in
(Node.node nnode).neg <- pnode; (* works because the neg field isn't taken into
account for hashing ! *)
pnode,nnode
-let empty_pair = StateSet.empty, StateSet.empty
-let true_,false_ = cons True False empty_pair empty_pair 0 0
+let true_,false_ = cons True False
let atom_ d p s =
- let si = StateSet.singleton s in
- let ss = match d with
- | `Left -> si, StateSet.empty
- | `Right -> StateSet.empty, si
- in fst (cons (Atom(d,p,s)) (Atom(d,not p,s)) ss ss 1 1)
+ fst (cons (Move(d,p,s)) (Move(d,not p,s)))
let not_ f = f.Node.node.neg
-let union_pair (l1,r1) (l2, r2) =
- StateSet.union l1 l2,
- StateSet.union r1 r2
-
-let merge_states f1 f2 =
- let sp =
- union_pair (st f1) (st f2)
- and sn =
- union_pair (st (not_ f1)) (st (not_ f2))
- in
- sp,sn
let order f1 f2 = if uid f1 < uid f2 then f2,f1 else f1,f2
(* commutativity of | *)
else
let f1, f2 = order f1 f2 in
- let psize = (size f1) + (size f2) in
- let nsize = (size (not_ f1)) + (size (not_ f2)) in
- let sp, sn = merge_states f1 f2 in
- fst (cons (Or(f1,f2)) (And(not_ f1, not_ f2)) sp sn psize nsize)
+ fst (cons (Or(f1,f2)) (And(not_ f1, not_ f2)))
let and_ f1 f2 =
loop 7
let hbit = Array.init 256 naive_highest_bit
- (*
- external clz : int -> int = "caml_clz" "noalloc"
- external leading_bit : int -> int = "caml_leading_bit" "noalloc"
- *)
+ (*
+ external clz : int -> int = "caml_clz" "noalloc"
+ external leading_bit : int -> int = "caml_leading_bit" "noalloc"
+ *)
let highest_bit x =
try
let n = (x) lsr 24 in
in
rmv t
- (* should run in O(1) thanks to Hash consing *)
+ (* should run in O(1) thanks to hash consing *)
let equal a b = Node.equal a b
let compare a b = (Uid.to_int (Node.uid a)) - (Uid.to_int (Node.uid b))
let rec merge s t =
- if (equal s t) (* This is cheap thanks to hash-consing *)
+ if equal s t (* This is cheap thanks to hash-consing *)
then s
else
match Node.node s, Node.node t with
include FiniteCofinite.Make(Ptset.Make(QName))
-module Weak = FiniteCofinite.Weak(Ptset.Weak(QName))
+let print_finite fmt e conv =
+ Format.fprintf fmt "{";
+ Pretty.print_list ~sep:"," QName.print fmt (conv e);
+ Format.fprintf fmt "}"
+
+let printer fmt e test conv inv =
+ if test e then print_finite fmt e conv
+ else begin
+ Format.fprintf fmt "%s \\ " Pretty.big_sigma;
+ print_finite fmt (inv e) conv
+ end
+
+let print fmt e = printer fmt e is_finite elements complement
+
+module Weak =
+struct
+ include FiniteCofinite.Weak(Ptset.Weak(QName))
+ let print fmt e = printer fmt e is_finite elements complement
+end