Common — library smtlib-low-level-theory.theory — module DSeqBoolImpl
356
module DSeqBoolImpl : DSeqBool
357
use Zbit
358
use DSeq
359
use int.MinMax
360
use int.Int
361
use ref.Ref
362
363
function
int_to_seq
(v:int) (len:int): seq bool =
364
from_array len false (fun i -> bittest v i)

Zero–extension: the bits past length s are always false, the default of s is ignored, following get_seq_to_int.

    No proof
368
let ghost function
seq_to_int
(s:seq bool) : int
369
ensures { forall j. 0 <= j ->
370
bittest result j = if j < length s then get s j else false }
371
=
372
let ref r = 0 in
373
for i=s.length-1 downto 0 do
374
invariant { forall j. 0 <= j ->
375
bittest r j = if j+i+1 < length s then get s (j+i+1) else false }
376
r := if get s i then 2*r+1 else 2*r
377
done;
378
r
379
380
end