diff options
| -rw-r--r-- | lib/concepts/Cardinality.ml | 6 | ||||
| -rw-r--r-- | lib/concepts/Mode.ml | 6 | ||||
| -rw-r--r-- | lib/concepts/Mode.mli | 1 |
3 files changed, 6 insertions, 7 deletions
diff --git a/lib/concepts/Cardinality.ml b/lib/concepts/Cardinality.ml index ac80a15..a87f9c8 100644 --- a/lib/concepts/Cardinality.ml +++ b/lib/concepts/Cardinality.ml @@ -4,7 +4,7 @@ let bounded n = if n <= 0 then Empty else Bounded n let rank = function Empty -> 0 | Bounded _ -> 1 | Finite -> 2 | Countable -> 3 let compare a b = - match (a, b) with + match a, b with | Bounded n, Bounded m -> Utilities.Ordering.of_int (Int.compare n m) | _ -> Utilities.Ordering.of_int (Int.compare (rank a) (rank b)) @@ -12,14 +12,16 @@ let equal a b = compare a b = Utilities.Ordering.Equal let leq a b = compare a b <> Utilities.Ordering.Greater let join a b = if leq a b then b else a let meet a b = if leq a b then a else b + let product a b = - match (a, b) with + match a, b with | Empty, _ | _, Empty -> Empty | Countable, _ | _, Countable -> Countable | Finite, _ | _, Finite -> Finite | Bounded n, Bounded m -> if n > max_int / m then Finite else bounded (n * m) let exhaustible = function Countable -> false | Empty | Bounded _ | Finite -> true + let to_string = function | Empty -> "empty" | Bounded n -> Printf.sprintf "bounded(%d)" n diff --git a/lib/concepts/Mode.ml b/lib/concepts/Mode.ml index 4d7501c..23abacf 100644 --- a/lib/concepts/Mode.ml +++ b/lib/concepts/Mode.ml @@ -5,14 +5,12 @@ type mode = {bound: attributes; affords: affordance} type t = mode list let attributes_of_list = BatSet.String.of_list - let decides_when bound = {bound= attributes_of_list bound; affords= Decides} let generates_when bound cardinality = {bound= attributes_of_list bound; affords= Generates cardinality} let enumerable cardinality = {bound= BatSet.String.empty; affords= Generates cardinality} - let empty = [] let declare mode declaration = mode :: declaration let of_list modes = modes @@ -33,7 +31,5 @@ let generation declaration bound = let decision declaration bound = List.exists (fun {bound= declared; affords} -> - match affords with - | Decides -> BatSet.String.equal declared bound - | Generates _ -> false ) + match affords with Decides -> BatSet.String.equal declared bound | Generates _ -> false ) declaration diff --git a/lib/concepts/Mode.mli b/lib/concepts/Mode.mli index 57b079f..982518a 100644 --- a/lib/concepts/Mode.mli +++ b/lib/concepts/Mode.mli @@ -23,4 +23,5 @@ val to_list : t -> mode list declared for fewer bound attributes applies to more, since the attributes left free are then fewer and no more numerous. *) val generation : t -> attributes -> Cardinality.t option + val decision : t -> attributes -> bool |
