Source file cp__DomI.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
type t = {
  min: Z.t;
  max: Z.t;
  }

type value = Z.t

let default_value (_: unit) : Z.t = Z.zero

let get_singleton (d: t) : Z.t =
  if not (Z.equal d.min d.max) then raise Cp__Type.Unsat; d.min

let is_singleton (d: t) : ((Z.t) list) Cp__Type.is_singleton =
  if Z.lt d.max d.min then raise Cp__Type.Unsat;
  if Z.equal d.max d.min
  then Cp__Type.Is_singleton
  else
    begin
      let rec interval (min: Z.t) (max: Z.t) : (Z.t) list =
        if Z.equal min max
        then min :: [] 
        else min :: interval (Z.add min Z.one) max in
      Cp__Type.Iter (interval d.min d.max) end

let mk_singleton (v: Z.t) : t = { min = v; max = v }