Skip to content

Commit

Permalink
upto transitivity (Hopcroft Karp)
Browse files Browse the repository at this point in the history
  • Loading branch information
smolkaj committed Apr 7, 2017
1 parent 5bf392a commit 1022bf9
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions lib/Frenetic_NetKAT_Equivalence.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
open Core.Std

module A = Frenetic_NetKAT_Compiler.Automaton
module Automaton = Frenetic_NetKAT_Compiler.Automaton
module FDD = Frenetic_NetKAT_Compiler.FDD

type state = FDD.t * FDD.t
Expand All @@ -11,12 +11,20 @@ module type UPTO = sig
end

module Upto_Sym () : UPTO = struct
(* FIXME: avoid polymorphic hash/max/min *)
(* FIXME: avoid polymorphic hash/max/min/equality *)
let cache = Hash_set.Poly.create ()
let equiv s1 s2 = Hash_set.mem cache (min s1 s2, max s1 s2)
let equiv s1 s2 = (s1 = s2) || Hash_set.mem cache (min s1 s2, max s1 s2)
let add_equiv s1 s2 = Hash_set.add cache (min s1 s2, max s1 s2)
end

module Upto_Trans () : UPTO = struct
(* FIXME: avoid polymorphic hash/max/min/equality *)
let cache = Hashtbl.Poly.create ()
let find = Hashtbl.find_or_add cache ~default:Union_find.create
let equiv s1 s2 = (s1 = s2) || Union_find.same_class (find s1) (find s2)
let add_equiv s1 s2 = Union_find.union (find s1) (find s2)
end

module Make_Naive(Upto : UPTO) = struct

module SymPkt = struct
Expand All @@ -41,7 +49,7 @@ module Make_Naive(Upto : UPTO) = struct



let equiv ?(pk=SymPkt.all) (a1 : A.t) (a2 : A.t) =
let equiv ?(pk=SymPkt.all) (a1 : Automaton.t) (a2 : Automaton.t) =

let rec eq_states pk (s1 : int) (s2 : int) =
let mask = SymPkt.to_alist pk in
Expand Down

1 comment on commit 1022bf9

@jnfoster
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet!

Please sign in to comment.