Module Katbv_lib.Bitstring
Type
type t
= (Base.int, Base.unit) Base.Hashtbl.t
the type of a bit string. AF: the table
H
represents a bitvectorv
wherev_i
=1 iff(i, ())
is inH
. Note that bit strings are interpreted left to right as highest bit to lowest bit. So the string 110 is the binary representation of 6 and (100)_0 = 0 whereas (100)_2 = 1
include Base.Comparator.S with type Bitstring.t := t
val comparator : (t, comparator_witness) Base.Comparator.comparator
Constructors
val zero : t
the zero bit string
val of_bool_list : Base.bool Base.list -> t
of_bool_list lst bv
is the bit stringv
wherev_i
=1 ifflst_i
=true
val of_int_list : Base.int Base.list -> t
of_int_list lst bv
the bit stringv
wherev_i
=1 iffi
is inlst
val of_binary : Base.string -> t
of_binary s
is the bit stringv
wherev_i
=1 iffs_i
="1"
Basic Operations
val max : t -> Base.int Base.option
max v
isSome i
wherei
is the maximum of {j:v_j
=1}
val min : t -> Base.int Base.option
min v
isSome i
wherei
is the minimum of {j:v_j
=1}
val is_zero : t -> Base.bool
is_zero v
is true iffv
=0
val nth : t -> Base.int -> Base.bool
nth v i
is true iffv_i
=1
KAT+B! functions
val lower_bound : Base.string -> t -> Katbb_lib.Ast.bexp
lower_bound s a
is KAT+B! Boolean expression that is satisfied bys:=v
iff v>=a wheres
is the variable name
val upper_bound : Base.string -> t -> Katbb_lib.Ast.bexp
upper_bound s b
is KAT+B! Boolean expression that is satisfied bys:=v
iffv
<=b
wheres
is the variable name
Rendering
val to_string : t -> Base.string