Skip to content

Commit

Permalink
use favonia code
Browse files Browse the repository at this point in the history
  • Loading branch information
jonsterling committed May 19, 2022
1 parent 3d9d352 commit ee2537a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 140 deletions.
4 changes: 4 additions & 0 deletions kado.opam
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@ depends: [
"dune" {>= "2.0"}
"ocaml" {>= "4.10"}
"bwd" {>= "1.0"}
"kusariyarou"
"odoc" {with-doc}
]
pin-depends: [
[ "kusariyarou.~dev" "git+https://github.com/favonia/kusariyarou" ]
]
build: [
["dune" "build" "-p" name "-j" jobs]
["dune" "build" "-p" name "-j" jobs "@runtest"] {with-test}
Expand Down
111 changes: 0 additions & 111 deletions src/Preorder.ml

This file was deleted.

15 changes: 0 additions & 15 deletions src/Preorder.mli

This file was deleted.

35 changes: 22 additions & 13 deletions src/Theory.ml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ struct
let compare = compare_dim
end

module Preorder = Preorder.Make (Vertex)
module K = Kusariyarou.Make (Vertex)
module VarSet = Set.Make (struct type t = var let compare = compare_var end)
module B = Builder.Free.Make (struct include P let equal_dim x y = Int.equal (compare x y) 0 end)

(** A presentation of an algebraic theory over the language of intervals and cofibrations. *)
type alg_thy' =
{preorder : Preorder.t;
{graph : K.t;
true_vars : VarSet.t}

type atom = LT of dim * dim
Expand Down Expand Up @@ -122,7 +122,7 @@ struct
type t' = alg_thy'

let emp' =
{preorder = Preorder.empty;
{graph = K.add_edge P.dim0 P.dim1 @@ K.add_vertex P.dim0 @@ K.add_vertex P.dim1 K.empty;
true_vars = VarSet.empty}

let empty =
Expand All @@ -137,7 +137,10 @@ struct
{thy with true_vars = VarSet.union vars thy.true_vars}

let test_lt (thy : t') (r, s) =
Preorder.has_path r s thy.preorder
if K.mem_vertex r thy.graph && K.mem_vertex s thy.graph then
K.reachable r s thy.graph
else
false

let test_eq (thy : t') (r, s) =
test_lt thy (r, s) && test_lt thy (s, r)
Expand All @@ -148,8 +151,11 @@ struct
if test_lt thy (r, s) then
true, thy
else
let preorder' = Preorder.insert r s thy.preorder in
false, {thy with preorder = preorder'}
let graph = thy.graph in
let graph = if K.mem_vertex r graph then graph else K.add_vertex r graph in
let graph = if K.mem_vertex s graph then graph else K.add_vertex s graph in
let graph = K.add_edge r s graph in
false, {thy with graph}

let test_var (thy : t') v =
VarSet.mem v thy.true_vars
Expand Down Expand Up @@ -217,13 +223,16 @@ struct
test_var thy' v

(* XXX: this function was never profiled *)
let meet2' thy'1 thy'2 =
let preorder = Preorder.union thy'1.preorder thy'2.preorder in
let true_vars = VarSet.union thy'1.true_vars thy'2.true_vars in
let thy' = {true_vars; preorder} in
match test_eq thy' (P.dim0, P.dim1) with
| true -> `Inconsistent
| false -> `Consistent thy'
let meet2' _thy'1 _thy'2 =
(* TODO: functionality not yet supported by library *)
failwith "TODO"

(* let preorder = Preorder.union thy'1.preorder thy'2.preorder in
let true_vars = VarSet.union thy'1.true_vars thy'2.true_vars in
let thy' = {true_vars; preorder} in
match test_eq thy' (P.dim0, P.dim1) with
| true -> `Inconsistent
| false -> `Consistent thy' *)

(* XXX: this function was never profiled *)
let meet2 thy1 thy2 =
Expand Down
2 changes: 1 addition & 1 deletion src/dune
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(library
(name Kado)
(libraries bwd)
(libraries bwd kusariyarou)
(public_name kado))

0 comments on commit ee2537a

Please sign in to comment.